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]

[PATCH] Obvious reload fix


OK, the subject is a little tongue in cheek, but this must come close to
qualifying.  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25432 has a
testcase where eliminate_regs_in_insn turns a (set (reg) (reg)) into
a (set (reg) (plus (reg) (const_int))) without properly re-recognizing
the insn.  eliminate_regs_in_insn calls recog() but doesn't update
INSN_CODE, thus a later call to recog_memoized in extract_insn returns
stale recog_data to find_reloads.

The lines of code I'm modifying appeared in r30134.  A comment 40 lines
or so before this place says: 

  /* If we are replacing a body that was a (set X (plus Y Z)), try to
     re-recognize the insn.  We do this in case we had a simple addition
     but now can do this as a load-address.  This saves an insn in this
     common case.
     If re-recognition fails, the old insn code number will still be used,
     and some register operands may have changed into PLUS expressions.
     These will be handled by find_reloads by loading them into a register
     again.  */

It seems that the intent was to update the insn code number when
successfully re-recognizing the insn otherwise the comment about keeping
the old number when it fails doesn't make sense.  The code here doesn't
make sense either, unless recog() at one stage updated the insn code
itself.

Tested with a "make quickstrap && make check" with no regressions on
powerpc64-linux.  Full bootstrap and regression test still in progress.

	PR rtl-optimization/25432
	* reload1.c (eliminate_regs_in_insn): Update insn code on
	successfully re-recognizing modified insn.

Index: gcc/reload1.c
===================================================================
--- gcc/reload1.c	(revision 108635)
+++ gcc/reload1.c	(working copy)
@@ -3233,8 +3233,8 @@ eliminate_regs_in_insn (rtx insn, int re
 	      || GET_CODE (SET_SRC (old_set)) == PLUS))
 	{
 	  int new_icode = recog (PATTERN (insn), insn, 0);
-	  if (new_icode < 0)
-	    INSN_CODE (insn) = icode;
+	  if (new_icode >= 0)
+	    INSN_CODE (insn) = new_icode;
 	}
     }
 
-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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