[GHC] #14283: Remove the special case for tagToEnum# in the code generator?
GHC
ghc-devs at haskell.org
Fri Sep 29 08:40:17 UTC 2017
#14283: Remove the special case for tagToEnum# in the code generator?
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: task | Status: new
Priority: normal | Milestone: 8.4.1
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
> The only remaining primop (aside from unsafeCoerce# and seq) that
produces an enumeration type is tagToEnum#. There is some magic in the
code generator to make garbage collection relating to this work as it has
historically.
What/where is the magic you want to remove? I think it might be
{{{
cgCase (StgOpApp (StgPrimOp op) args _) bndr (AlgAlt tycon) alts
| isEnumerationTyCon tycon -- Note [case on bool]
= do { tag_expr <- do_enum_primop op args
-- If the binder is not dead, convert the tag to a constructor
-- and assign it.
; unless (isDeadBinder bndr) $ do
{ dflags <- getDynFlags
; tmp_reg <- bindArgToReg (NonVoid bndr)
; emitAssign (CmmLocal tmp_reg)
(tagToClosure dflags tycon tag_expr) }
; (mb_deflt, branches) <- cgAlgAltRhss
(NoGcInAlts,AssignedDirectly)
(NonVoid bndr) alts
-- See Note [GC for conditionals]
; emitSwitch tag_expr branches mb_deflt 0 (tyConFamilySize tycon -
1)
; return AssignedDirectly
}
where
do_enum_primop :: PrimOp -> [StgArg] -> FCode CmmExpr
do_enum_primop TagToEnumOp [arg] -- No code!
= getArgAmode (NonVoid arg)
do_enum_primop primop args
= do dflags <- getDynFlags
tmp <- newTemp (bWord dflags)
cgPrimOp [tmp] primop args
return (CmmReg (CmmLocal tmp))
}}}
in `StgCmmExpr`. Right?
If so, what is the effect of just removing it? Why is it bad to have
{{{
case tagToEnum# x of y
DEFAULT -> f y
}}}
?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14283#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list