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: ping Dale's patches



On May 30, 2004, at 13:43, Roger Sayle wrote:
http://gcc.gnu.org/ml/gcc-patches/2004-04/msg01946.html
Patch: disable invalid REG_EQUAL note

I think its best to explore the "very dusty twisty little passages of darwin-specific address generation". I was going to approve this patch (with Andrews suggested change to use "== const0_rtx") when I realized that GCC's RTL canonicalization rules mean that the RTX "(MINUS X CONST_INT)" should never match! So Darwin (or the RTL optimizers) should be generating addresses as (PLUS X -C) instead of (MINUS X C), in addition to the fact that we should obviously never see either (MINUS X 0) or (PLUS X 0).

Do you have a test case, so that others can help investigate?

I do not have one but I think I have a patch which should make sure that those RTL do not get created in the first place, they only happen when dynamic-no-pic is turned on. Tested and bootstrapped on powerpc-apple-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
	* config/darwin.c (machopic_legitimize_pic_address): Set pic_base
	to NULL_RTX for dynamic-no-pic case.  Check for NULL pic_base and
	do not create RTL that reference const_zero.


Index: config/darwin.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v retrieving revision 1.68 diff -u -p -r1.68 darwin.c --- config/darwin.c 29 May 2004 02:55:23 -0000 1.68 +++ config/darwin.c 30 May 2004 17:59:10 -0000 @@ -624,9 +624,9 @@ machopic_legitimize_pic_address (rtx ori

/* if dynamic-no-pic then use 0 as the pic base */
if (MACHO_DYNAMIC_NO_PIC_P)
- pic_base = CONST0_RTX (Pmode);
+ pic_base = NULL_RTX;
else
- pic_base = gen_rtx_SYMBOL_REF (Pmode, machopic_function_base_name ());
+ pic_base = gen_rtx_SYMBOL_REF (Pmode, machopic_function_base_name ());


if (GET_CODE (orig) == MEM)
{
@@ -664,9 +664,10 @@ machopic_legitimize_pic_address (rtx ori
|| GET_CODE (XEXP (orig, 0)) == LABEL_REF)
{
rtx offset = gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- XEXP (orig, 0),
- pic_base));
+ pic_base == NULL_RTX ? XEXP (orig, 0) :
+ gen_rtx_MINUS (Pmode,
+ XEXP (orig, 0),
+ pic_base));
#if defined (TARGET_TOC) /* i.e., PowerPC */
/* Generating a new reg may expose opportunities for
common subexpression elimination. */
@@ -722,11 +723,13 @@ machopic_legitimize_pic_address (rtx ori
#endif


pic_ref = gen_rtx_PLUS (Pmode,
- pic,
+ pic,
gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- XEXP (orig, 0),
- pic_base)));
+ pic_base == NULL_RTX
+ ? XEXP (orig, 0) :
+ gen_rtx_MINUS (Pmode,
+ XEXP (orig, 0),
+ pic_base)));
}


 #if !defined (TARGET_TOC)
@@ -743,8 +746,10 @@ machopic_legitimize_pic_address (rtx ori
 	      || GET_CODE (orig) == LABEL_REF)
 	    {
 	      rtx offset = gen_rtx_CONST (Pmode,
-					  gen_rtx_MINUS (Pmode,
-							 orig, pic_base));
+                                   	  pic_base == NULL_RTX
+                                           ? orig:
+					     gen_rtx_MINUS (Pmode,
+							    orig, pic_base));
 #if defined (TARGET_TOC) /* i.e., PowerPC */
               rtx hi_sum_reg;

@@ -802,8 +807,11 @@ machopic_legitimize_pic_address (rtx ori
pic_ref = gen_rtx_PLUS (Pmode,
pic,
gen_rtx_CONST (Pmode,
- gen_rtx_MINUS (Pmode,
- orig, pic_base)));
+ pic_base == NULL_RTX
+ ? orig
+ : gen_rtx_MINUS (Pmode,
+ orig,
+ pic_base)));
}
}
}



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