Patchwork Followup for reg_equiv_invariant patch: Fix PR39871

login
register
mail settings
Submitter Bernd Schmidt
Date June 17, 2010, 9:53 p.m.
Message ID <4C1A9971.5000502@codesourcery.com>
Download mbox | patch
Permalink /patch/56092/
State New
Headers show

Comments

Bernd Schmidt - June 17, 2010, 9:53 p.m.
On 06/15/2010 12:55 PM, Bernd Schmidt wrote:
> On 06/15/2010 08:00 AM, Joern Rennecke wrote:
>> Quoting Jeff Law <law@redhat.com>:
>>
>>> On 06/14/10 20:35, Joern Rennecke wrote:
>>>> Quoting Bernd Schmidt <bernds@codesourcery.com>:
>>>>
>>>>> Joern, any comments - do you recall any reason why this change would
>>>>> have been intentional?
>>>>
>>>> What happens if we have a (plus (REG:SI SP_REG) (symbol_ref foo)) ?
>>>> Or will this never happen for flag_pic?
>>> I can't see how this would ever be valid when flag_pic.
>>
>> The question is if such invalid expressions might be in notes at these
>> points; if that might be the case, the code needs to reject them.
>>
>> function_invariant_p will accept them.
> 
> I guess we can change that and not lose anything.

This is what I committed after retesting on ARM (with -O2 -fpic included
in TORTURE_OPTIONS).


Bernd
IainS - July 24, 2010, 1:09 p.m.
On 17 Jun 2010, at 22:53, Bernd Schmidt wrote:

>
> This is what I committed after retesting on ARM (with -O2 -fpic  
> included
> in TORTURE_OPTIONS).

this caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45054

-mdynamic-no-pic  ? (yeah, a  ppc-darwin special, but worth 3..5% by  
reputation..)

If there's anything I can do to help debug, let me know.
cheers,
Iain

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 160946)
+++ ChangeLog	(working copy)
@@ -1,3 +1,12 @@ 
+2010-06-17  Bernd Schmidt  <bernds@codesourcery.com>
+
+	PR rtl-optimization/39871
+	* reload1.c (init_eliminable_invariants): For flag_pic, disable
+	equivalences only for constants that aren't LEGITIMATE_PIC_OPERAND_P.
+	(function_invariant_p): Rule out a plus of frame or arg pointer with
+	a SYMBOL_REF.
+	* ira.c (find_reg_equiv_invariant_const): Likewise.
+
 2010-06-17  Gunther Nikl  <gnikl@users.sourceforge.net>
 
 	* config/rs6000/rs6000.c (print_operand) <'K'>: Also use
Index: ira.c
===================================================================
--- ira.c	(revision 160946)
+++ ira.c	(working copy)
@@ -1586,12 +1586,8 @@  find_reg_equiv_invariant_const (void)
 
 	  x = XEXP (note, 0);
 
-	  if (! function_invariant_p (x)
-	      || ! flag_pic
-	      /* A function invariant is often CONSTANT_P but may
-		 include a register.  We promise to only pass CONSTANT_P
-		 objects to LEGITIMATE_PIC_OPERAND_P.  */
-	      || (CONSTANT_P (x) && LEGITIMATE_PIC_OPERAND_P (x)))
+	  if (! CONSTANT_P (x)
+	      || ! flag_pic || LEGITIMATE_PIC_OPERAND_P (x))
 	    {
 	      /* It can happen that a REG_EQUIV note contains a MEM
 		 that is not a legitimate memory operand.  As later
Index: reload1.c
===================================================================
--- reload1.c	(revision 160946)
+++ reload1.c	(working copy)
@@ -4151,13 +4151,9 @@  init_eliminable_invariants (rtx first, b
 	  if (i <= LAST_VIRTUAL_REGISTER)
 	    continue;
 
-	  if (! function_invariant_p (x)
-	      || ! flag_pic
-	      /* A function invariant is often CONSTANT_P but may
-		 include a register.  We promise to only pass
-		 CONSTANT_P objects to LEGITIMATE_PIC_OPERAND_P.  */
-	      || (CONSTANT_P (x)
-		  && LEGITIMATE_PIC_OPERAND_P (x)))
+	  /* If flag_pic and we have constant, verify it's legitimate.  */
+	  if (!CONSTANT_P (x)
+	      || !flag_pic || LEGITIMATE_PIC_OPERAND_P (x))
 	    {
 	      /* It can happen that a REG_EQUIV note contains a MEM
 		 that is not a legitimate memory operand.  As later
@@ -6004,7 +6000,7 @@  function_invariant_p (const_rtx x)
     return 1;
   if (GET_CODE (x) == PLUS
       && (XEXP (x, 0) == frame_pointer_rtx || XEXP (x, 0) == arg_pointer_rtx)
-      && CONSTANT_P (XEXP (x, 1)))
+      && GET_CODE (XEXP (x, 1)) == CONST_INT)
     return 1;
   return 0;
 }