patch applied (ghc): Desugar applications of ' seq' specially; fix Trac #1031

Simon Peyton Jones simonpj at microsoft.com
Fri Mar 16 11:19:57 EDT 2007


Fri Mar 16 08:17:12 PDT 2007  simonpj at microsoft.com
  * Desugar applications of 'seq' specially; fix Trac #1031
  
  Merge to 6.6 branch.  Test case is dsrun014.
  
  Note [Desugaring seq]  cf Trac #1031
  ~~~~~~~~~~~~~~~~~~~~~
     f x y = x `seq` (y `seq` (# x,y #))
  
  The [CoreSyn let/app invariant] means that, other things being equal, because 
  the argument to the outer 'seq' has an unlifted type, we'll use call-by-value thus:
  
     f x y = case (y `seq` (# x,y #)) of v -> x `seq` v
  
  But that is bad for two reasons: 
    (a) we now evaluate y before x, and 
    (b) we can't bind v to an unboxed pair
  
  Seq is very, very special!  So we recognise it right here, and desugar to
  	case x of _ -> case y of _ -> (# x,y #)
  
  The special case would be valid for all calls to 'seq', but it's only *necessary*
  for ones whose second argument has an unlifted type. So we only catch the latter
  case here, to avoid unnecessary tests.
  

    M ./compiler/deSugar/DsUtils.lhs -10 +30



More information about the Cvs-ghc mailing list