diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-02-19 11:03:15 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-03-01 17:31:36 -0500 |
commit | 6429943b0a377e076bcfd26c79ceb27cf2f4a9ab (patch) | |
tree | 0ea9b1e0ef0bb3cc0fa344f064034959f5fca4d8 /testsuite/tests/numeric | |
parent | 3b79e8b833646e995f035e4402f2284cc15cbd72 (diff) | |
download | haskell-6429943b0a377e076bcfd26c79ceb27cf2f4a9ab.tar.gz |
Fix terrible occurrence-analysis bug
Ticket #19360 showed up a terrible bug in the occurrence analyser,
in a situation like this
Rec { f = g
; g = ..f...
{-# RULE g .. = ...f... #-} }
Then f was postInlineUnconditionally, but not in the RULE (which
is simplified first), so we had a RULE mentioning a variable that
was not in scope.
This led me to review (again) the subtle loop-breaker stuff in the
occurrence analyser. The actual changes are few, and are largely
simplifications. I did a /lot/ of comment re-organising though.
There was an unexpected amount of fallout.
* Validation failed when compiling the stage2 compiler with profiling
on. That turned to tickle a second latent bug in the same OccAnal
code (at least I think it was always there), which led me to
simplify still further; see Note [inl_fvs] in GHC.Core.Opt.OccurAnal.
* But that in turn let me to some strange behaviour in CSE when ticks
are in the picture, which I duly fixed. See Note [Dealing with ticks]
in GHC.Core.Opt.CSE.
* Then I got an ASSERT failure in CoreToStg, which again seems to be
a latent bug. See Note [Ticks in applications] in GHC.CoreToStg
* I also made one unforced change: I now simplify the RHS of a RULE in
the same way as the RHS of a stable unfolding. This can allow a
trivial binding to disappear sooner than otherwise, and I don't
think it has any downsides. The change is in
GHC.Core.Opt.Simplify.simplRules.
Diffstat (limited to 'testsuite/tests/numeric')
-rw-r--r-- | testsuite/tests/numeric/should_compile/T7116.stdout | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/testsuite/tests/numeric/should_compile/T7116.stdout b/testsuite/tests/numeric/should_compile/T7116.stdout index 996d391b44..8560ad4a10 100644 --- a/testsuite/tests/numeric/should_compile/T7116.stdout +++ b/testsuite/tests/numeric/should_compile/T7116.stdout @@ -62,11 +62,9 @@ dl :: Double -> Double Arity=1, Str=<SP(U)>, Cpr=m1, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once1!] :: Double) -> - case x of { GHC.Types.D# y -> GHC.Types.D# (GHC.Prim.+## y y) }}] + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] dl = dr -- RHS size: {terms: 8, types: 3, coercions: 0, joins: 0/0} @@ -94,13 +92,9 @@ fl :: Float -> Float Arity=1, Str=<SP(U)>, Cpr=m1, - Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True, + Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True, WorkFree=True, Expandable=True, - Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False) - Tmpl= \ (x [Occ=Once1!] :: Float) -> - case x of { GHC.Types.F# y -> - GHC.Types.F# (GHC.Prim.plusFloat# y y) - }}] + Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}] fl = fr |