summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SimplCore.hs
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-02-06 15:11:21 +0100
committerAndreas Klebinger <klebinger.andreas@gmx.at>2020-02-06 17:04:27 +0100
commitc2886bf608b283ce9034a1cf5ad854b8b9286b5e (patch)
treee85ac268370530d7018f992d3bd3fb5ddf767ecc /compiler/simplCore/SimplCore.hs
parent5e63d9c07c0585b85c8fa340d30aeff0130af3f4 (diff)
downloadhaskell-wip/andreask/T17724.tar.gz
Fix #17724 by running the simplifier before late CSEwip/andreask/T17724
CSE seems to depend on bindings being in dependency order. The simplifier put's bindings into dependency order. So do a simplifier run first. We used to do in order * ... * optional: late spec + simplifier "post-late-spec" run * optional: late cse * simplifier "final" run * ... We now do: * ... * optional: late spec * optional: simplifier "pre-late-cse" run + cse * simplifier "final" run. * ... The result is that: * At -O we now potentially do fewer runs of the simplifier. "post-late-spec" is gone if late-spec is on * At -O2 we do an additional simplifier run : "pre-late-cse" * At -O2 with -fspec-late we do what we already did. Only that the intermediate simplifier run is called "pre-late-cse" instead of "post-late-spec". We also removed a case where occAnal dropped code it assumed to be dead.
Diffstat (limited to 'compiler/simplCore/SimplCore.hs')
-rw-r--r--compiler/simplCore/SimplCore.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs
index b8fb162432..799dfa93fe 100644
--- a/compiler/simplCore/SimplCore.hs
+++ b/compiler/simplCore/SimplCore.hs
@@ -318,15 +318,17 @@ getCoreToDo dflags
maybe_rule_check (Phase 0),
- runWhen late_specialise
- (CoreDoPasses [ CoreDoSpecialising
- , simpl_phase 0 ["post-late-spec"] max_iter]),
+ runWhen late_specialise CoreDoSpecialising,
-- LiberateCase can yield new CSE opportunities because it peels
-- off one layer of a recursive function (concretely, I saw this
-- in wheel-sieve1), and I'm guessing that SpecConstr can too
-- And CSE is a very cheap pass. So it seems worth doing here.
+ -- This helps shake out any effect of liberate_case/spec_constr.
+ -- It also puts bindings in dependency order, which helps with CSE.
runWhen ((liberate_case || spec_constr) && cse) CoreCSE,
+ ( CoreDoPasses [ simpl_phase 0 ["pre-late-cse"] max_iter
+ , CoreCSE ]),
-- Final clean-up simplification:
simpl_phase 0 ["final"] max_iter,