#5075: CPR optimisation for sum types if only one constructor is used
---------------------------------+------------------------------------------
    Reporter:  batterseapower    |       Owner:              
        Type:  feature request   |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:  7.0.3             |    Keywords:              
    Testcase:                    |   Blockedby:              
          Os:  Unknown/Multiple  |    Blocking:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 Inspired by #3138, it might be useful for StrAnal to detect functions such
 as the following where only one of the data constructors for a sum type
 are CPRed:

 {{{
 loop x = case x < 10 of True -> Left x; False -> loop (x*2)
 }}}

 We can usefully transform to:

 {{{
 $wloop x = case (case x < 10 of True -> Left x; False -> loop (x*2)) of
 Left y -> (# y #)
 loop x = case loop x of (# y #) -> Left y
 }}}

 Attached patch implements this behaviour. Most of the complication in the
 new code occurs because adding a DataCon field to the Demand data type
 means that we have to define a separate IfaceDemand type for storage in
 interface files.

 The patch validates but I haven't done any tests on nofib. I have
 confirmed that the new optimisation hits on some examples, though.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5075>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to