Skip to content

CSE fails to CSE two identical large top-level functions

Consider this code:

module CSEBug where

data Succs a = Succs a [a]

instance Functor Succs where
    fmap f (Succs o s) = Succs (f o) (map f s)

foo, bar :: (a -> b) -> (b -> c) -> Succs a -> Succs c
foo f g x = fmap (g . f) x
bar f g x = fmap (g . f) x

If I compile this with -O, foo and bar are not CSEd, which can be seen with -ddump-cse.

Removing either the first or the second argument of Succs makes CSE work.

Is there a size limit on CSE?

Edited by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information