Make rewrite rules "win" over inlining
If a rewrite rule and a rewrite rule compete in the simplifier, this patch makes sure that the rewrite rule "win". That is, in general a bit fragile, but it's a huge help when making specialisation work reliably, as #21851 and #22097 showed. The change is fairly straightforwad, and documented in Note [Rewrite rules and inlining] in GHC.Core.Opt.Simplify.Iteration. Compile-times change, up and down a bit -- in some cases because we get better specialisation. But the payoff (more reliable specialisation) is large. Metrics: compile_time/bytes allocated ----------------------------------------------- T10421(normal) +3.7% BAD T10421a(normal) +5.5% T13253(normal) +1.3% T14052(ghci) +1.8% T15304(normal) -1.4% T16577(normal) +3.1% BAD T17516(normal) +2.3% T17836(normal) -1.9% T18223(normal) -1.8% T8095(normal) -1.3% T9961(normal) +2.5% BAD geo. mean +0.0% minimum -1.9% maximum +5.5% Nofib results are (bytes allocated) +-------------------------------++----------+ | ||tsv (rel) | +===============================++==========+ | imaginary/paraffins || +0.27% | | imaginary/rfib || -0.04% | | real/anna || +0.02% | | real/fem || -0.04% | | real/fluid || +1.68% | | real/gamteb || -0.34% | | real/gg || +1.54% | | real/hidden || -0.01% | | real/hpg || -0.03% | | real/infer || -0.03% | | real/prolog || +0.02% | | real/veritas || -0.47% | | shootout/fannkuch-redux || -0.03% | | shootout/k-nucleotide || -0.02% | | shootout/n-body || -0.06% | | shootout/spectral-norm || -0.01% | | spectral/cryptarithm2 || +1.25% | | spectral/fibheaps || +18.33% | | spectral/last-piece || -0.34% | +===============================++==========+ | geom mean || +0.17% | There are extensive notes in !8897 about the regressions. Briefly * fibheaps: there was a very delicately balanced inlining that tipped over the wrong way after this change. * cryptarithm2 and paraffins are caused by #22274, which is a separate issue really. (I.e. the right fix is *not* to make inlining "win" over rules.) So I'm accepting these changes Metric Increase: T10421 T16577 T9961
parent
d83a92e6
Pipeline #57616 passed with warnings
Stage: tool-lint
Stage: quick-build
Stage: full-build
Stage: packaging
Stage: testing
Showing
- compiler/GHC/Core/Opt/Simplify/Iteration.hs 131 additions, 85 deletionscompiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs 85 additions, 72 deletionscompiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Utils/Monad.hs 4 additions, 1 deletioncompiler/GHC/Utils/Monad.hs
- testsuite/tests/lib/integer/Makefile 4 additions, 2 deletionstestsuite/tests/lib/integer/Makefile
- testsuite/tests/simplCore/should_compile/T21851.hs 15 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T21851.hs
- testsuite/tests/simplCore/should_compile/T21851.stderr 19 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T21851.stderr
- testsuite/tests/simplCore/should_compile/T21851a.hs 5 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T21851a.hs
- testsuite/tests/simplCore/should_compile/T22097.hs 7 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T22097.hs
- testsuite/tests/simplCore/should_compile/T22097.stderr 46 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T22097.stderr
- testsuite/tests/simplCore/should_compile/T22097a.hs 23 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T22097a.hs
- testsuite/tests/simplCore/should_compile/T6056.stderr 1 addition, 1 deletiontestsuite/tests/simplCore/should_compile/T6056.stderr
- testsuite/tests/simplCore/should_compile/all.T 4 additions, 0 deletionstestsuite/tests/simplCore/should_compile/all.T
Loading
Please register or sign in to comment