From df5ba475e3acb59010b6ede2d7815a61b7749ce7 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sat, 31 Dec 2005 00:39:42 +0000 Subject: [PATCH] re PR target/25213 ([3.4 only] -fpic/-fPIC testsuite failures in gcc.dg/i386-387-3.c and i386-387-4.c) PR target/25213 Backport from mainline 2005-09-06 Jakub Jelinek 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. From-SVN: r109192 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/config/i386/i386.md | 10 ++++------ gcc/cse.c | 3 +++ gcc/rtl.h | 1 + gcc/simplify-rtx.c | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr23098.c | 25 +++++++++++++++++++++++++ 7 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr23098.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6ef23390c8a..6952318a919f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2005-12-30 Roger Sayle + + PR target/25213 + Backport from mainline + 2005-09-06 Jakub Jelinek + + 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-12-30 John David Anglin PR fortran/25586 diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index e87a31663237..0fbe00b66e3c 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -2174,11 +2174,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. @@ -2891,11 +2890,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) diff --git a/gcc/cse.c b/gcc/cse.c index 447d972c340a..72af39aa4f3b 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -3518,6 +3518,9 @@ fold_rtx (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) base = addr; diff --git a/gcc/rtl.h b/gcc/rtl.h index d75789fd8217..c95ac847e6a5 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1639,6 +1639,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); /* In function.c */ extern rtx gen_mem_addressof (rtx, tree, int); diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 7c0263061ae4..d6d8f89d62ca 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -188,6 +188,14 @@ simplify_gen_ternary (enum rtx_code code, enum machine_mode mode, 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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5de9c3cdec3f..aa0a842a72ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-12-30 Roger Sayle + + PR target/25213 + * gcc.dg/pr23098.c: Backport testcase from mainline. + 2005-12-27 Kaveh R. Ghazi * g++.dg/rtti/tinfo1.C: Scan for ".global" also. diff --git a/gcc/testsuite/gcc.dg/pr23098.c b/gcc/testsuite/gcc.dg/pr23098.c new file mode 100644 index 000000000000..d1750b735f97 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr23098.c @@ -0,0 +1,25 @@ +/* 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; +} -- 2.47.2