Skip to content

CSE missing an easy case

Consider this Core:

case f @Int of { r1 ->
case f @Int of { r2 -> ...

There is an easy common sub-expression to be had here, which would allow to eliminate a case expression, but CSE didn't spot it in GHC 8.

Easy to fix. Here's an example that shows it

module Bug where

f g x = let r :: [a] -> [a]
            r = case g x of True  -> reverse . reverse
                            False -> reverse
        in
        r `seq` r `seq` True
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information