#4930: Case-of-case not eliminated when it could be
---------------------------------+------------------------------------------
    Reporter:  rl                |       Owner:                         
        Type:  bug               |      Status:  new                    
    Priority:  normal            |   Component:  Compiler               
     Version:  7.1               |    Keywords:                         
    Testcase:                    |   Blockedby:                         
          Os:  Unknown/Multiple  |    Blocking:                         
Architecture:  Unknown/Multiple  |     Failure:  Runtime performance bug
---------------------------------+------------------------------------------
 Small example:

 {{{
 foo :: Int -> Int
 foo n = (if n < 5 then error "Too small" else n+2) `seq` n+5
 }}}

 GHC produces this:

 {{{
 foo =
   \ (w_slQ :: Int) ->
     case w_slQ of _ { I# ww_slT ->
     case case <# ww_slT 5 of _ {
            False -> case +# ww_slT 2 of sat_sm1 { __DEFAULT -> I# sat_sm1
 };
            True -> foo1
          }
     of _ { I# _ ->
     case +# ww_slT 5 of sat_sm4 { __DEFAULT -> I# sat_sm4 }
     }
     }
 }}}

 It ought to produce something like this instead:

 {{{
 foo n = case n of I# n# ->
         case n# <# 5 of
           True -> foo1
           False -> I# (n# +# 5)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4930>
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