summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2023-03-10 16:04:41 +0100
committerSebastian Graf <sebastian.graf@kit.edu>2023-03-10 16:04:44 +0100
commit96002b19d415c7e6236173620e239158702d9ca2 (patch)
tree43e0c1e8c9ef26bd96aa610720e3b5f00a08537e
parent9ea719f2f1929bf2b789e4001f6c542a04185d61 (diff)
downloadhaskell-wip/cheaper-eta.tar.gz
Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` checkwip/cheaper-eta
There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf.
-rw-r--r--compiler/GHC/Core/Opt/Simplify/Utils.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Core/Opt/Simplify/Utils.hs b/compiler/GHC/Core/Opt/Simplify/Utils.hs
index ffecebd876..3a1dd75d1f 100644
--- a/compiler/GHC/Core/Opt/Simplify/Utils.hs
+++ b/compiler/GHC/Core/Opt/Simplify/Utils.hs
@@ -1859,11 +1859,12 @@ tryEtaExpandRhs :: SimplEnv -> BindContext -> OutId -> OutExpr
-> SimplM (ArityType, OutExpr)
-- See Note [Eta-expanding at let bindings]
tryEtaExpandRhs env bind_cxt bndr rhs
- | do_eta_expand -- If the current manifest arity isn't enough
- -- (never true for join points)
- , seEtaExpand env -- and eta-expansion is on
- , wantEtaExpansion rhs
- = -- Do eta-expansion.
+ | seEtaExpand env -- If Eta-expansion is on
+ , wantEtaExpansion rhs -- and we'd like to eta-expand e
+ , do_eta_expand -- and e's manifest arity is lower than
+ -- what it could be
+ -- (never true for join points)
+ = -- Do eta-expansion.
assertPpr( not (isJoinBC bind_cxt) ) (ppr bndr) $
-- assert: this never happens for join points; see GHC.Core.Opt.Arity
-- Note [Do not eta-expand join points]