Skip to content
  • Simon Peyton Jones's avatar
    [project @ 2004-04-27 12:47:13 by simonpj] · 74e0bdb6
    Simon Peyton Jones authored
    ----------------------------------------
         1. Make primOpIsCheap do something sensible
         2. Make the state hack work better
         ----------------------------------------
    
    1.  In March 2001, we changed primOpIsCheap to
    	primOpIsCheap op = False
    thereby making *no* primops seem cheap.  But this killed eta
    expansion on case (x ==# y) of True -> \s -> ...
    which is bad.  In particular a loop like
      doLoop n = loop 0
        where
          loop i | i == n    = return ()
                 | otherwise = bar i >> loop (i+1)
    allocated a closure every time round because it didn't eta expand.
    
    The problem that made us set primOpIsCheap to False was
    		let x = a +# b *# c in x +# x
    where we don't want to inline x. But primopIsCheap doesn't control
    that (it's exprIsDupable that does) so the problem doesn't occur
    even if primOpIsCheap sometimes says 'True'.  I think that perhaps
    something changed since March 2001.
    
    
    2.  Consider this
    	case x of
    	  True  -> \(s:RealWorld) -> e
    	  False -> foo
    where foo has arity 1.  If we are using the "state hack" we want to
    eta expand here.  This commit fixes arityType in the Var case (for foo)
    to take account of foo's type.
    
    Also add -fno-state-hack to the static flags, to allow the state hack to
    be switched off.
    74e0bdb6