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]

Patch to rtx_varies_p to improve pic code on PA


The main purpose of this patch is to improve pic code on the PA.  Treating
the high part of symbol references accessed using the pic offset table
register as constant allows REG_EQUIV notes to be added to these insns.
This improves cse elimination for identical references.

The pic offset table register on the PA is call clobbered.  Previously,
there was a problem in the restoration of the pic offset table register
after a call if the register was treated as constant.  However, the method
of saving and restoring the register was changed recently and the
register can now be treated as constant without affecting the restore
after calls.

As far as I can tell, the only other port potentially affected by this
portion of the patch is the ia64 which also has a call clobbered pic
offset table register.

A secondary purpose of this patch is to consolidate rtx_varies_p and
rtx_unstable_p.  I have added code rtx_varies_p to treat an unchanging
register as constant for alias analysis.  The two previous callers
of rtx_unstable_p have been changed to call rtx_varies_p.  The only
difference resulting from this change is that rtx_varies_p is more
conservative than rtx_varies_p with respect to unchanging registers.

Bootstrapped under hppa1.1 hpux 10.20, i686 linux and vax ultrix.
Checked with hppa1.1 hpux 10.20 and i686 linux.

Please review for main.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-03-09  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* explow.c (stabilize): Call rtx_varies_p instead of rtx_unstable_p.
	* regmove.c (stable_and_no_regs_but_for_p): Likewise.
	* rtlanal.c (rtx_varies_p): Treat an unchanging register operand as
	constant for alias analysis.  Treat the pic offset table register as
	constant even when PIC_OFFSET_TABLE_REG_CALL_CLOBBERED is defined.
	Update comments.

--- explow.c.orig	Tue Feb 13 01:39:45 2001
+++ explow.c	Tue Mar  6 15:13:28 2001
@@ -723,7 +723,7 @@
     return x;
 
   addr = XEXP (x, 0);
-  if (rtx_unstable_p (addr))
+  if (rtx_varies_p (addr, 0))
     {
       rtx temp = force_reg (Pmode, copy_all_regs (addr));
       rtx mem = gen_rtx_MEM (GET_MODE (x), temp);
--- regmove.c.orig	Tue Jan 30 19:20:44 2001
+++ regmove.c	Tue Mar  6 15:15:21 2001
@@ -2062,7 +2062,7 @@
 	return 0;
       /* fall through */
     default:
-      return ! rtx_unstable_p (x);
+      return ! rtx_varies_p (x, 0);
     }
 }
 
--- rtlanal.c.orig	Fri Mar  9 10:39:55 2001
+++ rtlanal.c	Fri Mar  9 11:46:40 2001
@@ -110,12 +110,15 @@
   return 0;
 }
 
-/* Return 1 if X has a value that can vary even between two
-   executions of the program.  0 means X can be compared reliably
-   against certain constants or near-constants.
-   FOR_ALIAS is nonzero if we are called from alias analysis; if it is
-   zero, we are slightly more conservative.
-   The frame pointer and the arg pointer are considered constant.  */
+/* Return 1 if X has a value that can vary even between two executions
+   of the program.  0 means X can be compared reliably against certain
+   constants or near-constants.
+   FOR_ALIAS is nonzero if we are called from alias analysis.  If it is
+   nonzero we check if X varies at its current location.  If it is zero,
+   we are more conservative and check if it would vary if substituted
+   at any point in the current function.
+   The frame pointer, hard frame pointer, arg pointer when fixed, and
+   the pic offset table rtx are considered constant within a function.  */
 
 int
 rtx_varies_p (x, for_alias)
@@ -148,17 +151,13 @@
 	 for pseudos.  */
       if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
 	  /* The arg pointer varies if it is not a fixed register.  */
-	  || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
-	return 0;
-      if (x == pic_offset_table_rtx
-#ifdef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
-	  /* ??? When call-clobbered, the value is stable modulo the restore
-	     that must happen after a call.  This currently screws up
-	     local-alloc into believing that the restore is not needed, so we
-	     must return 0 only if we are called from alias analysis.  */
-	  && for_alias
+	  || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM])
+#ifdef PIC_OFFSET_TABLE_REGNUM
+	  || (x == pic_offset_table_rtx)
 #endif
-	  )
+	  /* Except for alias analysis, an unchanging register varies
+	     because it may die.  */
+	  || (for_alias && RTX_UNCHANGING_P (x)))
 	return 0;
       return 1;
 


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