This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR 27073: invalid gcse manipulation of REG_EQUIV notes


Richard Sandiford <richard@codesourcery.com> writes:
> Roger Sayle <roger@eyesopen.com> writes:
>> The difference cconcerns this test from later in try_replace_reg:
>>
>>       if (!success && note == 0 && set != 0
>>
>> Previously for instructions containing REG_EQUIV notes, note would
>> be non-zero, however it now indicates whether we had a REG_EQUAL
>> note.  This will now lead to situations where our instruction will
>> have both REG_EQUAL and REG_EQUIV notes, as GCSE may now blindly
>> add a REG_EQUAL note if the substitution isn't a valid instruction.
>> This may or may not confuse later passes, for example the function
>> find_reg_equal_equiv_note assumes there's only or other note, and
>> reload changes notes from one form to another, which will result
>> in multiple notes.
>
> OK, if that's what bothers you, I'll change it.  Patch to come.

As below.  Bootstrapped & regression-tested on i686-pc-linux-gnu.
I also made sure that the arm-eabi failure stayed fixed.  OK to install?

Richard


	PR rtl-optimization/27073
	* gcse.c (try_replace_reg): Revert last change.  Continue to search
	for both REG_EQUAL and REG_EQUIV notes, but only perform replacements
	on the former.

Index: gcc/gcse.c
===================================================================
--- gcc/gcse.c	(revision 112803)
+++ gcc/gcse.c	(working copy)
@@ -2640,11 +2640,11 @@ find_used_regs (rtx *xptr, void *data AT
    Returns nonzero is successful.  */
 
 static int
 try_replace_reg (rtx from, rtx to, rtx insn)
 {
-  rtx note = find_reg_note (insn, REG_EQUAL, NULL);
+  rtx note = find_reg_equal_equiv_note (insn);
   rtx src = 0;
   int success = 0;
   rtx set = single_set (insn);
 
   validate_replace_src_group (from, to, insn);
@@ -2658,13 +2658,13 @@ try_replace_reg (rtx from, rtx to, rtx i
 
       if (src)
 	validate_change (insn, &SET_SRC (set), src, 0);
     }
 
-  /* If there is already a NOTE, update the expression in it with our
-     replacement.  */
-  if (note != 0)
+  /* If there is already a REG_EQUAL note, update the expression in it
+     with our replacement.  */
+  if (note != 0 && REG_NOTE_KIND (note) == REG_EQUAL)
     XEXP (note, 0) = simplify_replace_rtx (XEXP (note, 0), from, to);
 
   if (!success && set && reg_mentioned_p (from, SET_SRC (set)))
     {
       /* If above failed and this is a single set, try to simplify the source of
@@ -2687,11 +2687,11 @@ try_replace_reg (rtx from, rtx to, rtx i
 
   /* 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
      reg-reg move, but be on the safe side.  */
-  if (note && REG_P (XEXP (note, 0)))
+  if (note && REG_NOTE_KIND (note) == REG_EQUAL && REG_P (XEXP (note, 0)))
     remove_note (insn, note);
 
   return success;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]