[project @ 2001-03-05 12:45:45 by simonpj]
authorsimonpj <unknown>
Mon, 5 Mar 2001 12:45:45 +0000 (12:45 +0000)
committersimonpj <unknown>
Mon, 5 Mar 2001 12:45:45 +0000 (12:45 +0000)
commite6dff21dfefdae928aa1577a294595865f8c22f6
tree6ad7fd5cb93bae3e3e04900b04ec1f7ec4d22a10
parentb5cad075afeeebb30e3603c23e7a1c511bff36a8
[project @ 2001-03-05 12:45:45 by simonpj]
Improve SpecConstr

This commit fixes SpecConstr so that it can see the effect of
enclosing case expressions properly.  That's what the "cons" field
in ScEnv is for.

As a result, consider this function:

  data AccessPath = Cont  AccessPath
  | Value Int

  demandAll n ap@(Cont (Value (I# i1)))
    = case n of
0     -> i1
other -> i1 +# demandAll (n-1) ap

SpecConstr now successfully compiles it to this:

  $s$wdemandAll
    = \ i1 :: PrelGHC.Int# sc :: PrelGHC.Int# ->
      case sc of ds {
0 -> i1;
__DEFAULT -> PrelGHC.+# i1 (Foo.$s$wdemandAll i1 (PrelGHC.-# ds 1))
      }

with the rule

 "SC:$wdemandAll1" __forall i1 :: PrelGHC.Int# ,
    sc :: PrelGHC.Int# .
Foo.$wdemandAll sc (Foo.$wCont (Foo.$wValue (PrelBase.$wI# i1)))
= Foo.$s$wdemandAll i1 sc ;
ghc/compiler/main/DriverState.hs
ghc/compiler/specialise/SpecConstr.lhs