summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmSink.hs
diff options
context:
space:
mode:
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