Make recursion and RULES interact better
authorsimonpj@microsoft.com <unknown>
Tue, 3 Oct 2006 15:30:57 +0000 (15:30 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 3 Oct 2006 15:30:57 +0000 (15:30 +0000)
commitc248518fe81b6d2807d3bcbb8a09ae14facce1ad
treee42ca4be596391f2ef649b3721cb74fc5017d5f0
parentf297deab8887f3f6e9462e1c89598391c099bbb1
Make recursion and RULES interact better

See Trac #683

This patch improves the interaction of recursion and RULES; at least I
hope it does.   The problem was that a RULE was being treated uniformly like
an "extra RHS". This worked badly when you have a non-recursive definition
that is made recursive only by RULE.

This patch maeks the occurrence analyser know whether a binder is referred to
only from RULES (the RulesOnly constructor in OccInfo).  Then we can ignore
such edges when deciding on the order of bindings in a letrec, and when
setting the LoopBreaker flag.

The remaining potential problem is this:
rec{ f = ...g...
   ; g = ...f...
     RULE g True = ...
   }

The RULE for g may not be visible in f's rhs.  This is fixable, but not
today.
compiler/basicTypes/BasicTypes.lhs
compiler/main/TidyPgm.lhs
compiler/simplCore/OccurAnal.lhs
compiler/simplCore/Simplify.lhs