summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorklebinger.andreas@gmx.at <klebinger.andreas@gmx.at>2019-04-02 14:20:12 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-04-03 00:34:57 -0400
commit5a75ccd0993ff2fdf827824e28ae7db4ad9c25ad (patch)
treeefae16bdc9be651f85148a6ef68fc38d2664215b
parentbf73419518ca550e85188616f860961c7e2a336b (diff)
downloadhaskell-5a75ccd0993ff2fdf827824e28ae7db4ad9c25ad.tar.gz
Fix faulty substitutions in StgCse (#11532).
`substBndr` should rename bindings which shadow existing ids. However while it was renaming the bindings it was not adding proper substitutions for renamed bindings. Instead of adding a substitution of the form `old -> new` for renamed bindings it mistakenly added `old -> old` if no replacement had taken place while adding none if `old` had been renamed. As a byproduct this should improve performance, as we no longer add useless substitutions for unshadowed bindings.
-rw-r--r--compiler/simplStg/StgCse.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/simplStg/StgCse.hs b/compiler/simplStg/StgCse.hs
index 386515ee27..269738e488 100644
--- a/compiler/simplStg/StgCse.hs
+++ b/compiler/simplStg/StgCse.hs
@@ -245,8 +245,8 @@ substBndr env old_id
new_id = uniqAway (ce_in_scope env) old_id
no_change = new_id == old_id
env' = env { ce_in_scope = ce_in_scope env `extendInScopeSet` new_id }
- new_env | no_change = env' { ce_subst = extendVarEnv (ce_subst env) old_id new_id }
- | otherwise = env'
+ new_env | no_change = env'
+ | otherwise = env' { ce_subst = extendVarEnv (ce_subst env) old_id new_id }
substBndrs :: CseEnv -> [InVar] -> (CseEnv, [OutVar])
substBndrs env bndrs = mapAccumL substBndr env bndrs