re PR rtl-optimization/23098 (store of 0.0 to float)
authorJakub Jelinek <jakub@redhat.com>
Tue, 6 Sep 2005 08:53:11 +0000 (10:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 6 Sep 2005 08:53:11 +0000 (10:53 +0200)
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.

From-SVN: r103935

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/cse.c
gcc/rtl.h
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr23098.c [new file with mode: 0644]

index 3ab98bebd50bfe9118aea6d062b6e48e111d98b1..3bcc27c1179896fcda8d7ff9a67df04784ca8a6d 100644 (file)
@@ -1,3 +1,13 @@
+2005-09-06  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.
+
 2005-09-06  Andreas Krebbel  <krebbel1@de.ibm.com>
 
        * gcse.c (try_replace_reg): Disallow REG_EQUAL notes for 
index 88440d66183c15b7cec3202b6ee1c40d4bfa8dac..c1d455a600fa691b258f1908142be7aff6488976 100644 (file)
        (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.
    && 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)
index 1efcf308ae4ced72e6314dae719ca3749cd900ef..713b842dcc0da6f4f65f82200c848257b740db73 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -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)
index 1692033e491c793b7bb3282e59217b1a185aeb59..6de76e288f3b22dd795af3b8c2ff2a18e88c6398 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1542,6 +1542,7 @@ extern rtx simplify_gen_subreg (enum machine_mode, rtx, enum machine_mode,
 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  */
index 13e90e99bfdda27b00b44dde76aa4acd9bb18e29..d3ec956c1aece5e63d2a5ae42897dd604ef55747 100644 (file)
@@ -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;
+}
 \f
 /* Make a unary operation by first seeing if it folds and otherwise making
    the specified operation.  */
index 5602451da9786e336f3a479da89741ded0f0769e..e1b8b0b21b99f3806c83d539433a70cad9cc59be 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/23098
+       * gcc.target/i386/pr23098.c: New test.
+
 2005-09-05  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/23667
diff --git a/gcc/testsuite/gcc.target/i386/pr23098.c b/gcc/testsuite/gcc.target/i386/pr23098.c
new file mode 100644 (file)
index 0000000..3a3fd10
--- /dev/null
@@ -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;
+}