This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] delegitimize pic constructs in more places (PR rtl-optimization/23098)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Sep 2005 13:31:28 -0400
- Subject: [PATCH] delegitimize pic constructs in more places (PR rtl-optimization/23098)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
PR23098 (regression from 3.2) shows several regressions on -fpic, where
floating point constants forced once into memory are optimized as expected
(say into fldz, fld1 etc.) when -fno-pic, but fail to be optimized when
-fpic.
This seems to be because CSE etc. don't see through the PIC constructs.
avoid_constant_pool_reference (together with dwarf2out.c) already uses the
delegitimize_address hook for this purpose, so this patch just adds
a call to this hook into CSE and changes 2 i386 splitters to call
avoid_constant_pool_reference instead of doing it's job by hand
(and without doing address delegitimization or checking stored constant
mode as opposed to MEM's mode).
Bootstrapped/regtested on i386-linux, ok to commit if I bootstrap/regtest
this on a couple of other arches?
2005-09-02 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/23098
* cse.c (fold_rtx_mem): Call delegitimize_address target hook.
* config/i386/i386.md (pushf split, mov[sdx]f split): Use
avoid_constant_pool_reference instead of just get_pool_constant.
* 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-02 16:44:25.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))"
+ && avoid_constant_pool_reference (operands[1]) != 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))"
+ && avoid_constant_pool_reference (operands[1]) != 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/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