Case-of-case not eliminated when it could be
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)
Trac metadata
Trac field | Value |
---|---|
Version | 7.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |