Demand: Clear distinction between Call SubDmd and eval Dmd (#21717)
In #21717 (closed) we saw a reportedly unsound strictness signature due to an unsound
definition of plusSubDmd on Calls. This patch contains a description and the fix
to the unsoundness as outlined in Note [Call SubDemand vs. evaluation Demand]
.
This fix means we also get rid of the special handling of -fpedantic-bottoms
in eta-reduction. Thanks to less strict and actually sound strictness results,
we will no longer eta-reduce the problematic cases in the first place, even
without -fpedantic-bottoms
.
So fixing the unsoundness also makes our eta-reduction code simpler with less
hacks to explain. But there is another, more unfortunate side-effect:
We unfix #21085 (closed), but fortunately we have a new fix ready:
See Note [mkCall and plusSubDmd]
.
There's another change:
I decided to make Note [SubDemand denotes at least one evaluation]
a lot
simpler by using plusSubDmd
(instead of lubPlusSubDmd
) even if both argument
demands are lazy. That leads to less precise results, but in turn rids ourselves
from the need for 4 different OpMode
s and the complication of
Note [Manual specialisation of lub*Dmd/plus*Dmd]
. The result is simpler code
that is in line with the paper draft on Demand Analysis.
I left the abandoned idea in Note [Unrealised opportunity in plusDmd]
for
posterity. The fallout in terms of regressions is negligible, as the testsuite
and NoFib shows.
Program Allocs Instrs
--------------------------------------------------------------------------------
hidden +0.2% -0.2%
linear -0.0% -0.7%
--------------------------------------------------------------------------------
Min -0.0% -0.7%
Max +0.2% +0.0%
Geometric Mean +0.0% -0.0%
Fixes #21717 (closed).