
#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 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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. We want to get rid of the special case. Simply removing it altogether actually does seem to work, but the code we generate likely isn't quite the same. The challenge here is that (despite what I thought earlier) we definitely ''can'' end up in code generation, under certain circumstances, with {{{#!hs case tagToEnum# @t x of ... }}} How does this happen? After all, in `caseRules` we carefully remove every case on `tagToEnum#` and `dataToTag#` applications! The trouble comes when CorePrep puts everything in A-normal form. Strict function applications are transformed into `case` forms, so {{{#!hs f (tagToEnum# x) }}} will become {{{#!hs case tagToEnum# x of y DEFAULT -> f y }}} Suddenly we have that ugly case! Hmph. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14283 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler