[3.4 PATCH] PR target/25213: Backport PR rtl-optimization/23098
Roger Sayle
roger@eyesopen.com
Fri Dec 30 23:59:00 GMT 2005
The following patch backports Jakub Jelinek's fix for PR23098 from
mainline (and the 4.0 branch) to gcc 3.4. Kaveh recently filed PR25213
pointing out that 3.4 contains a missed optimization regression that
was causing two testsuite testcases to FAIL when run with -fpic/-fPIC.
Investigating further, it turns out that this is the same problem as
PR23098, which although recognized by Andrew Pinski as a potential
3.4 regression (on x86 with -fpic), was never applied to the 3.4 branch.
The following patch bas been tested against the gcc-3_4-branch with a
full "make bootstrap", all default languages, and regression tested with
a top-level "make -k check" with no new failures. The new testcase has
been tweaked a little as 3.4 doesn't have a gcc.target directory.
I'm happy that the changes themselves are fairly safe (they've been on
mainline for a few months without problems), but the ultimate decision
of whether this is suitable for the release branch should be the RMs.
Missed-optimization regressions are lesser regressions, and closing
this PR as WONTFIX might not be unreasonable.
Ok for the gcc-3_4-branch?
2005-12-30 Roger Sayle <roger@eyesopen.com>
PR target/25213
Backport from mainline
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.
* gcc.dg/pr23098.c: Backport testcase from mainline.
Index: cse.c
===================================================================
*** cse.c (revision 109154)
--- cse.c (working copy)
*************** fold_rtx (rtx x, rtx insn)
*** 3518,3523 ****
--- 3518,3526 ----
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)
base = addr;
Index: simplify-rtx.c
===================================================================
*** simplify-rtx.c (revision 109154)
--- simplify-rtx.c (working copy)
*************** simplify_gen_ternary (enum rtx_code code
*** 188,193 ****
--- 188,201 ----
return gen_rtx_fmt_eee (code, mode, op0, op1, op2);
}
+
+ /* 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;
+ }
/* Likewise, for relational operations.
CMP_MODE specifies mode comparison is done in.
Index: rtl.h
===================================================================
*** rtl.h (revision 109154)
--- rtl.h (working copy)
*************** extern rtx simplify_gen_subreg (enum mac
*** 1639,1644 ****
--- 1639,1645 ----
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);
/* In function.c */
extern rtx gen_mem_addressof (rtx, tree, int);
Index: config/i386/i386.md
===================================================================
*** config/i386/i386.md (revision 109154)
--- config/i386/i386.md (working copy)
***************
*** 2174,2184 ****
(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))"
[(set (match_dup 0)
(match_dup 1))]
! "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
;; %%% Kill this when call knows how to work this out.
--- 2174,2183 ----
(match_operand:SF 1 "memory_operand" ""))]
"reload_completed
&& GET_CODE (operands[1]) == MEM
! && constant_pool_reference_p (operands[1])"
[(set (match_dup 0)
(match_dup 1))]
! "operands[1] = avoid_constant_pool_reference (operands[1]);")
;; %%% Kill this when call knows how to work this out.
***************
*** 2891,2901 ****
&& 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))"
[(set (match_dup 0) (match_dup 1))]
{
! rtx c = get_pool_constant (XEXP (operands[1], 0));
rtx r = operands[0];
if (GET_CODE (r) == SUBREG)
--- 2890,2899 ----
&& GET_CODE (operands[1]) == MEM
&& (GET_MODE (operands[0]) == XFmode
|| GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
! && constant_pool_reference_p (operands[1])"
[(set (match_dup 0) (match_dup 1))]
{
! rtx c = avoid_constant_pool_reference (operands[1]);
rtx r = operands[0];
if (GET_CODE (r) == SUBREG)
/* PR rtl-optimization/23098 */
/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -fPIC" } */
/* { dg-final { scan-assembler-not "\.LC\[0-9\]" } } */
/* { dg-require-effective-target ilp32 } */
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;
}
Roger
--
More information about the Gcc-patches
mailing list