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: [PATCH] delegitimize pic constructs in more places (PR rtl-optimization/23098)


On Sun, Sep 04, 2005 at 10:37:38AM -0700, Richard Henderson wrote:
> On Sat, Sep 03, 2005 at 06:19:38AM -0400, Jakub Jelinek wrote:
> > So I really don't know what exactly should rtl_for_decl_location be
> > doing for delegitimization.
> 
> revision 1.365
> date: 2002/04/16 06:18:37;  author: jakub;  state: Exp;  lines: +10 -1

Oops, it has been a long time ago, clearly I forgot completely about it.

> > I think the only outstanding question is
> > if there should be a separate predicate for constant pool references,
> > but it should IMHO cover all cases that avoid_constant_pool_reference
> > checks for (e.g. even the mode and offset into the constant), so
> > either code should just use the
> > avoid_constant_pool_reference (x) != x
> > predicate directly, or there should be a tiny function that does the same.
> 
> A tiny function would be a bit less odd than that as a bare expression.

Ok, here is an updated patch, ok for HEAD/4.0?

2005-09-05  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/23098
	* cse.c (fold_rtx_mem): Call delegitimize_address target hook.
	* simplify-rtx.c (constant_pool_reference_p): New function.
	* rtl.h (constant_pool_reference_p): New prototype.
	* config/i386/i386.md (pushf split, mov[sdx]f split): Use
	constant_pool_reference_p in condition and
	avoid_constant_pool_reference in preparation statements.

	* gcc.target/i386/pr23098.c: New test.

--- gcc/cse.c.jj	2005-08-06 10:39:54.000000000 +0200
+++ gcc/cse.c	2005-09-02 16:12:10.000000000 +0200
@@ -3462,6 +3462,9 @@ fold_rtx_mem (rtx x, rtx insn)
 	  addr = addr_ent->const_rtx;
       }
 
+    /* Call target hook to avoid the effects of -fpic etc....  */
+    addr = targetm.delegitimize_address (addr);
+
     /* If address is constant, split it into a base and integer
        offset.  */
     if (GET_CODE (addr) == SYMBOL_REF || GET_CODE (addr) == LABEL_REF)
--- gcc/config/i386/i386.md.jj	2005-08-27 10:12:50.000000000 +0200
+++ gcc/config/i386/i386.md	2005-09-05 10:03:12.000000000 +0200
@@ -2247,11 +2247,10 @@
 	(match_operand:SF 1 "memory_operand" ""))]
   "reload_completed
    && GET_CODE (operands[1]) == MEM
-   && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
-   && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
+   && constant_pool_reference_p (operands[1])"
   [(set (match_dup 0)
 	(match_dup 1))]
-  "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
+  "operands[1] = avoid_constant_pool_reference (operands[1]);")
 
 
 ;; %%% Kill this when call knows how to work this out.
@@ -2861,11 +2860,10 @@
    && GET_CODE (operands[1]) == MEM
    && (GET_MODE (operands[0]) == XFmode
        || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
-   && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
-   && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
+   && constant_pool_reference_p (operands[1])"
   [(set (match_dup 0) (match_dup 1))]
 {
-  rtx c = get_pool_constant (XEXP (operands[1], 0));
+  rtx c = avoid_constant_pool_reference (operands[1]);
   rtx r = operands[0];
 
   if (GET_CODE (r) == SUBREG)
--- gcc/rtl.h.jj	2005-08-27 10:12:46.000000000 +0200
+++ gcc/rtl.h	2005-09-05 09:59:28.000000000 +0200
@@ -1542,6 +1542,7 @@ extern rtx simplify_gen_subreg (enum mac
 extern rtx simplify_replace_rtx (rtx, rtx, rtx);
 extern rtx simplify_rtx (rtx);
 extern rtx avoid_constant_pool_reference (rtx);
+extern bool constant_pool_reference_p (rtx x);
 extern bool mode_signbit_p (enum machine_mode, rtx);
 
 /* In regclass.c  */
--- gcc/simplify-rtx.c.jj	2005-08-21 15:27:00.000000000 +0200
+++ gcc/simplify-rtx.c	2005-09-05 09:58:47.000000000 +0200
@@ -209,6 +209,14 @@ avoid_constant_pool_reference (rtx x)
 
   return x;
 }
+
+/* Return true if X is a MEM referencing the constant pool.  */
+
+bool
+constant_pool_reference_p (rtx x)
+{
+  return avoid_constant_pool_reference (x) != x;
+}
 
 /* Make a unary operation by first seeing if it folds and otherwise making
    the specified operation.  */
--- gcc/testsuite/gcc.target/i386/pr23098.c.jj	2005-09-02 16:51:22.000000000 +0200
+++ gcc/testsuite/gcc.target/i386/pr23098.c	2005-09-02 16:51:42.000000000 +0200
@@ -0,0 +1,24 @@
+/* PR rtl-optimization/23098 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fPIC" } */
+/* { dg-final { scan-assembler-not "\.LC\[0-9\]" } } */
+
+double foo (float);
+
+double
+f1 (void)
+{
+  return foo (1.0);
+}
+
+double
+f2 (void)
+{
+  return foo (0.0);
+}
+
+void
+f3 (float *x, float t)
+{
+  *x = 0.0 + t;
+}


	Jakub


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