Rules and join points
From Note [Rules and join points] in OccurAnal:
Things get fiddly with rules. Suppose we have:
let j :: Int -> Int
j y = 2 * y
k :: Int -> Int -> Int
{-# RULES "SPEC k 0" k 0 = j #-}
k x y = x + 2 * y
in ...
Now suppose that both j and k appear only as saturated tail calls in the body. Thus we would like to make them both join points. The rule complicates matters, though, as its RHS has an unapplied occurrence of j. //However//, if we were to eta-expand the rule, all would be well:
{-# RULES "SPEC k 0" forall a. k 0 a = j a #-}
So conceivably we could notice that a potential join point would have an
"undersaturated" rule and account for it. This would mean we could make
something that's been specialised a join point, for instance. But local bindings
are rarely specialised, and being overly cautious about rules only
costs us anything when, for some j:
-
Before specialisation,
jhas non-tail calls, so it can't be a join point. -
During specialisation,
jgets specialised and thus acquires rules. -
Sometime afterward, the non-tail calls to
jdisappear (as dead code, say),and so now
j//could// become a join point.
This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |