cvs commit: fptools/ghc/compiler/basicTypes Id.lhs fptools/ghc/compiler/coreSyn CoreUtils.lhs fptools/ghc/compiler/main CmdLineOpts.lhs fptools/ghc/compiler/prelude PrimOp.lhs

Simon Peyton Jones simonpj at glass.cse.ogi.edu
Tue Apr 27 06:47:21 EDT 2004


simonpj     2004/04/27 05:47:21 PDT

  Modified files:
    ghc/compiler/basicTypes Id.lhs 
    ghc/compiler/coreSyn CoreUtils.lhs 
    ghc/compiler/main    CmdLineOpts.lhs 
    ghc/compiler/prelude PrimOp.lhs 
  Log:
       ----------------------------------------
       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.
  
  Revision  Changes    Path
  1.121     +8 -6      fptools/ghc/compiler/basicTypes/Id.lhs
  1.125     +19 -9     fptools/ghc/compiler/coreSyn/CoreUtils.lhs
  1.186     +1 -1      fptools/ghc/compiler/main/CmdLineOpts.lhs
  1.106     +19 -4     fptools/ghc/compiler/prelude/PrimOp.lhs


More information about the Cvs-ghc mailing list