Patch to improve PIC find_base_term

John Wehle john@feith.com
Sun Aug 20 21:11:00 GMT 2000


This patch allows alias analysis to understand PIC addresses.  The
BRL-CAD raytracing benchmarks show 1-5 percent improvement with it.
This patch passes make bootstrap and make check on FreeBSD-3.5 x86.

ChangeLog:

Mon Aug 21 00:00:24 EDT 2000  John Wehle  (john@feith.com)

	* alias.c (find_base_term): Handle the pic register.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/alias.c.ORIGINAL	Thu Aug 17 22:38:52 2000
--- gcc/alias.c	Sun Aug 20 03:06:26 2000
*************** find_base_term (x)
*** 1078,1083 ****
--- 1078,1100 ----
  	   is a shift or multiply, then it must be the index register and the
  	   other operand is the base register.  */
  	
+ 	if (tmp1 == pic_offset_table_rtx && CONSTANT_P (tmp2))
+ 	  {
+ 	    x = XEXP (tmp2, 0);
+ 	    if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == CONST_INT)
+ 	      x = XEXP (x, 0);
+ 	    /* Assume that an address containing the pic register and
+ 	       a constant unspec label_ref (or symbol_ref) is being used
+ 	       to access that label (or symbol).  In some cases the address
+ 	       is actually used to load the address of the label or symbol
+ 	       from the GOT.  Returning the label_ref (or symbol_ref) should
+ 	       be safe even in these situations since the GOT is read-only.  */
+ 	    if (GET_CODE (x) == UNSPEC && XVECLEN (x, 0) == 1)
+ 	      x = XVECEXP (x, 0, 0);
+ 	    return (GET_CODE (x) == LABEL_REF || GET_CODE (x) == SYMBOL_REF)
+ 		   ? x : 0;
+ 	  }
+ 
  	/* If either operand is known to be a pointer, then use it
  	   to determine the base term.  */
  	if (REG_P (tmp1) && REGNO_POINTER_FLAG (REGNO (tmp1)))
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



More information about the Gcc-patches mailing list