PR rtl-optimization/50448
authorgjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Nov 2011 13:08:54 +0000 (13:08 +0000)
committergjl <gjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Nov 2011 13:08:54 +0000 (13:08 +0000)
* cprop.c (try_replace_reg): Also try to replace uses of FROM that
appear in SET_DEST.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181011 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cprop.c

index 5288438..e92bd18 100644 (file)
@@ -1,3 +1,9 @@
+2011-11-05  Georg-Johann Lay  <avr@gjlay.de>
+
+       PR rtl-optimization/50448
+       * cprop.c (try_replace_reg): Also try to replace uses of FROM that
+       appear in SET_DEST.
+
 2011-11-05  Peter Dufault  <dufault@hda.com>,
            Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
index 584ffd2..d90f769 100644 (file)
@@ -712,8 +712,8 @@ find_used_regs (rtx *xptr, void *data ATTRIBUTE_UNUSED)
     }
 }
 
-/* Try to replace all non-SET_DEST occurrences of FROM in INSN with TO.
-   Returns nonzero is successful.  */
+/* Try to replace all uses of FROM in INSN with TO.
+   Return nonzero if successful.  */
 
 static int
 try_replace_reg (rtx from, rtx to, rtx insn)
@@ -764,6 +764,18 @@ try_replace_reg (rtx from, rtx to, rtx insn)
        note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src));
     }
 
+  if (set && MEM_P (SET_DEST (set)) && reg_mentioned_p (from, SET_DEST (set)))
+    {
+      /* Registers can also appear as uses in SET_DEST if it is a MEM.
+         We could perhaps try this for multiple SETs, but it probably
+         won't buy us anything.  */
+      rtx dest = simplify_replace_rtx (SET_DEST (set), from, to);
+      
+      if (!rtx_equal_p (dest, SET_DEST (set))
+          && validate_change (insn, &SET_DEST (set), dest, 0))
+        success = 1;
+    }
+
   /* REG_EQUAL may get simplified into register.
      We don't allow that. Remove that note. This code ought
      not to happen, because previous code ought to synthesize