Fix arityType: -fpedantic-bottoms, join points, etc
This MR fixes #21694, #21755. It also makes sure that #21948 and fix to #21694. * For #21694 the underlying problem was that we were calling arityType on an expression that had free join points. This is a Bad Bad Idea. See Note [No free join points in arityType]. * To make "no free join points in arityType" work out I had to avoid trying to use eta-expansion for runRW#. This entailed a few changes in the Simplifier's treatment of runRW#. See GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#] * I also made andArityType work correctly with -fpedantic-bottoms; see Note [Combining case branches: andWithTail]. * Rewrote Note [Combining case branches: optimistic one-shot-ness] * arityType previously treated join points differently to other let-bindings. This patch makes them unform; arityType analyses the RHS of all bindings to get its ArityType, and extends am_sigs. I realised that, now we have am_sigs giving the ArityType for let-bound Ids, we don't need the (pre-dating) special code in arityType for join points. But instead we need to extend the env for Rec bindings, which weren't doing before. More uniform now. See Note [arityType for let-bindings]. This meant we could get rid of ae_joins, and in fact get rid of EtaExpandArity altogether. Simpler. * And finally, it was the strange treatment of join-point Ids in arityType (involving a fake ABot type) that led to a serious bug: #21755. Fixed by this refactoring, which treats them uniformly; but without breaking #18328. In fact, the arity for recursive join bindings is pretty tricky; see the long Note [Arity for recursive join bindings] in GHC.Core.Opt.Simplify.Utils. That led to more refactoring, including deciding that an Id could have an Arity that is bigger than its JoinArity; see Note [Invariants on join points], item 2(b) in GHC.Core * Make sure that the "demand threshold" for join points in DmdAnal is no bigger than the join-arity. In GHC.Core.Opt.DmdAnal see Note [Demand signatures are computed for a threshold arity based on idArity] * I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity, where it more properly belongs. * Remove an old, redundant hack in FloatOut. The old Note was Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels. Compile time improves very slightly on average: Metrics: compile_time/bytes allocated --------------------------------------------------------------------------------------- T18223(normal) ghc/alloc 725,808,720 747,839,216 +3.0% BAD T6048(optasm) ghc/alloc 105,006,104 101,599,472 -3.2% GOOD geo. mean -0.2% minimum -3.2% maximum +3.0% For some reason Windows was better T10421(normal) ghc/alloc 125,888,360 124,129,168 -1.4% GOOD T18140(normal) ghc/alloc 85,974,520 83,884,224 -2.4% GOOD T18698b(normal) ghc/alloc 236,764,568 234,077,288 -1.1% GOOD T18923(normal) ghc/alloc 75,660,528 73,994,512 -2.2% GOOD T6048(optasm) ghc/alloc 112,232,512 108,182,520 -3.6% GOOD geo. mean -0.6% I had a quick look at T18223 but it is knee deep in coercions and the size of everything looks similar before and after. I decided to accept that 3% increase in exchange for goodness elsewhere. Metric Decrease: T10421 T18140 T18698b T18923 T6048 Metric Increase: T18223
parent
a9f0e68e
Pipeline #56161 canceled
Stage: tool-lint
Stage: quick-build
Stage: full-build
Stage: packaging
Stage: testing
Stage: deploy
Showing
- compiler/GHC/Core.hs 28 additions, 13 deletionscompiler/GHC/Core.hs
- compiler/GHC/Core/Lint.hs 3 additions, 3 deletionscompiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Opt/Arity.hs 406 additions, 267 deletionscompiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/DmdAnal.hs 44 additions, 25 deletionscompiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/FloatOut.hs 4 additions, 10 deletionscompiler/GHC/Core/Opt/FloatOut.hs
- compiler/GHC/Core/Opt/SetLevels.hs 20 additions, 29 deletionscompiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs 58 additions, 31 deletionscompiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs 89 additions, 17 deletionscompiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/WorkWrap.hs 5 additions, 6 deletionscompiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Tidy.hs 41 additions, 26 deletionscompiler/GHC/Core/Tidy.hs
- compiler/GHC/Core/Utils.hs 2 additions, 57 deletionscompiler/GHC/Core/Utils.hs
- compiler/GHC/Iface/Tidy.hs 8 additions, 8 deletionscompiler/GHC/Iface/Tidy.hs
- testsuite/tests/arityanal/should_compile/T21755.hs 11 additions, 0 deletionstestsuite/tests/arityanal/should_compile/T21755.hs
- testsuite/tests/arityanal/should_compile/T21755.stderr 1 addition, 0 deletionstestsuite/tests/arityanal/should_compile/T21755.stderr
- testsuite/tests/arityanal/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/arityanal/should_compile/all.T
- testsuite/tests/arityanal/should_run/T21694a.hs 27 additions, 0 deletionstestsuite/tests/arityanal/should_run/T21694a.hs
- testsuite/tests/arityanal/should_run/T21694a.stderr 3 additions, 0 deletionstestsuite/tests/arityanal/should_run/T21694a.stderr
- testsuite/tests/arityanal/should_run/all.T 4 additions, 0 deletionstestsuite/tests/arityanal/should_run/all.T
- testsuite/tests/simplCore/should_compile/T21694.hs 91 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T21694.hs
- testsuite/tests/simplCore/should_compile/T21694b.hs 6 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T21694b.hs
Loading
Please register or sign in to comment