summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmSink.hs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-08-02 10:36:58 +0100
committerSimon Marlow <marlowsd@gmail.com>2012-08-02 11:57:30 +0100
commit3ae875c45d7d228514547be639d30042d6bf1d26 (patch)
tree4deaa81fa89245df5dea203c3fad3e8640e5d40e /compiler/cmm/CmmSink.hs
parent95686360bb8898e77b2998d3aec11a4e2c31c4ad (diff)
downloadhaskell-3ae875c45d7d228514547be639d30042d6bf1d26.tar.gz
Eliminate "r = r" assignments.
Previously these were caught by removeDeadAssignments, but we aren't doing that now.
Diffstat (limited to 'compiler/cmm/CmmSink.hs')
-rw-r--r--compiler/cmm/CmmSink.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/cmm/CmmSink.hs b/compiler/cmm/CmmSink.hs
index 02195c91e1..80c6eed349 100644
--- a/compiler/cmm/CmmSink.hs
+++ b/compiler/cmm/CmmSink.hs
@@ -205,7 +205,12 @@ walk nodes assigs = go nodes emptyBlock assigs
-- to get all the dead code, but it catches the common case of
-- superfluous reloads from the stack that the stack allocator
-- leaves behind.
+ --
+ -- Also we catch "r = r" here. You might think it would fall
+ -- out of inlining, but the inliner will see that r is live
+ -- after the instruction and choose not to inline r in the rhs.
discard = case node of
+ CmmAssign r (CmmReg r') | r == r' -> True
CmmAssign (CmmLocal r) _ -> not (r `Set.member` live)
_otherwise -> False