[commit: ghc] master: Eliminate "r = r" assignments. (3ae875c)

Simon Marlow marlowsd at gmail.com
Thu Aug 2 14:20:59 CEST 2012


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/3ae875c45d7d228514547be639d30042d6bf1d26

>---------------------------------------------------------------

commit 3ae875c45d7d228514547be639d30042d6bf1d26
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Aug 2 10:36:58 2012 +0100

    Eliminate "r = r" assignments.
    
    Previously these were caught by removeDeadAssignments, but we aren't
    doing that now.

>---------------------------------------------------------------

 compiler/cmm/CmmSink.hs |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/compiler/cmm/CmmSink.hs b/compiler/cmm/CmmSink.hs
index 02195c9..80c6eed 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
   





More information about the Cvs-ghc mailing list