Patchwork : Fix PR rtl-optimization/50448

login
register
mail settings
Submitter Georg-Johann Lay
Date Nov. 5, 2011, 11:24 a.m.
Message ID <4EB51CF5.3020002@gjlay.de>
Download mbox | patch
Permalink /patch/123834/
State New
Headers show

Comments

Georg-Johann Lay - Nov. 5, 2011, 11:24 a.m.
Paolo Bonzini wrote:
> On 11/04/2011 09:50 AM, Eric Botcazou wrote:
>> +   /* If above failed and this is a single set, try to simplify the
>> source of
>> +      the set given our substitution.  We could perhaps try this for
>> multiple
>> +      SETs, but it probably won't buy us anything.  */
>> +    rtx addr = simplify_replace_rtx (SET_DEST (set), from, to);
>>
>> What does "If above failed" refer to?  Again "source" instead of
>> "destination".
> 
> What about
> 
>    /* 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.  */
> 
> ?
> 
> Georg, can you put it all together into a v2?
> 
> Paolo

Like so?

	PR rtl-optimization/50448
	* cprop.c (try_replace_reg): Also try to replace uses of FROM that
	appear in SET_DEST.

IMO the head comment is still misleading because it might give rise to the
assumption that SET_DESTs are replaced, too, which is not the case.

Johann
Eric Botcazou - Nov. 5, 2011, 11:45 a.m.
> 	PR rtl-optimization/50448
> 	* cprop.c (try_replace_reg): Also try to replace uses of FROM that
> 	appear in SET_DEST.

OK if it passes testing, with s/addr/dest/ as addr isn't an address at all.

> IMO the head comment is still misleading because it might give rise to the
> assumption that SET_DESTs are replaced, too, which is not the case.

"use" is to be understood as opposed to "set" so SET_DEST itself is excluded.
Georg-Johann Lay - Nov. 5, 2011, 1:11 p.m.
Eric Botcazou wrote:
>> 	PR rtl-optimization/50448
>> 	* cprop.c (try_replace_reg): Also try to replace uses of FROM that
>> 	appear in SET_DEST.
> 
> OK if it passes testing, with s/addr/dest/ as addr isn't an address at all.

Ok, it's here:

http://gcc.gnu.org/viewcvs?view=revision&revision=181011

Johann

Patch

Index: cprop.c
===================================================================
--- cprop.c	(revision 180962)
+++ cprop.c	(working copy)
@@ -712,8 +712,8 @@  find_used_regs (rtx *xptr, void *data AT
     }
 }
 
-/* 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 i
 	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 addr = simplify_replace_rtx (SET_DEST (set), from, to);
+      
+      if (!rtx_equal_p (addr, SET_DEST (set))
+          && validate_change (insn, &SET_DEST (set), addr, 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