aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2004-10-30 00:56:59 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2004-10-30 00:56:59 +0000
commit5976e643ed10a021367870663b1105aaf064393a (patch)
tree3e72bc5f754672ecac841d4642054de785714fa0 /gcc
parent8b5a12daa03d076b8b57dc565333eecb8d1880d0 (diff)
downloadgcc-5976e643ed10a021367870663b1105aaf064393a.zip
gcc-5976e643ed10a021367870663b1105aaf064393a.tar.gz
gcc-5976e643ed10a021367870663b1105aaf064393a.tar.bz2
re PR rtl-optimization/17581 (Long long arithmetic fails inside a switch/case statement when compiled with -O2)
PR rtl-optimization/17581 * cselib.c (cselib_process_insn): The last instruction of a libcall block, with the REG_RETVAL note, should be considered in the libcall. * gcse.c (do_local_cprop): Allow constants to be propagated outside of libcall blocks. (adjust_libcall_notes): Use simplify_replace_rtx instead of replace_rtx to avoid creating invalid RTL in REG_RETVAL notes. * gcc.dg/pr17581-1.c: New test case. From-SVN: r89873
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/cselib.c8
-rw-r--r--gcc/gcse.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr17581-1.c28
5 files changed, 52 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ae5c94b..6ac0249 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2004-10-29 Roger Sayle <roger@eyesopen.com>
+
+ PR rtl-optimization/17581
+ * cselib.c (cselib_process_insn): The last instruction of a libcall
+ block, with the REG_RETVAL note, should be considered in the libcall.
+ * gcse.c (do_local_cprop): Allow constants to be propagated outside
+ of libcall blocks.
+ (adjust_libcall_notes): Use simplify_replace_rtx instead of
+ replace_rtx to avoid creating invalid RTL in REG_RETVAL notes.
+
2004-10-30 Kazu Hirata <kazu@cs.umass.edu>
* tree-phinodes.c (create_phi_node): Don't zero PHI_REWRITTEN.
diff --git a/gcc/cselib.c b/gcc/cselib.c
index e58f2541..eb0b52a 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -1346,8 +1346,6 @@ cselib_process_insn (rtx insn)
if (find_reg_note (insn, REG_LIBCALL, NULL))
cselib_current_insn_in_libcall = true;
- if (find_reg_note (insn, REG_RETVAL, NULL))
- cselib_current_insn_in_libcall = false;
cselib_current_insn = insn;
/* Forget everything at a CODE_LABEL, a volatile asm, or a setjmp. */
@@ -1358,12 +1356,16 @@ cselib_process_insn (rtx insn)
&& GET_CODE (PATTERN (insn)) == ASM_OPERANDS
&& MEM_VOLATILE_P (PATTERN (insn))))
{
+ if (find_reg_note (insn, REG_RETVAL, NULL))
+ cselib_current_insn_in_libcall = false;
clear_table ();
return;
}
if (! INSN_P (insn))
{
+ if (find_reg_note (insn, REG_RETVAL, NULL))
+ cselib_current_insn_in_libcall = false;
cselib_current_insn = 0;
return;
}
@@ -1399,6 +1401,8 @@ cselib_process_insn (rtx insn)
if (GET_CODE (XEXP (x, 0)) == CLOBBER)
cselib_invalidate_rtx (XEXP (XEXP (x, 0), 0));
+ if (find_reg_note (insn, REG_RETVAL, NULL))
+ cselib_current_insn_in_libcall = false;
cselib_current_insn = 0;
if (n_useless_values > MAX_USELESS_VALUES)
diff --git a/gcc/gcse.c b/gcc/gcse.c
index f1e1b0a..f277801 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -3134,7 +3134,8 @@ do_local_cprop (rtx x, rtx insn, int alter_jumps, rtx *libcall_sp)
rtx this_rtx = l->loc;
rtx note;
- if (l->in_libcall)
+ /* Don't CSE non-constant values out of libcall blocks. */
+ if (l->in_libcall && ! CONSTANT_P (this_rtx))
continue;
if (gcse_constant_p (this_rtx))
@@ -3222,7 +3223,7 @@ adjust_libcall_notes (rtx oldreg, rtx newval, rtx insn, rtx *libcall_sp)
return true;
}
}
- XEXP (note, 0) = replace_rtx (XEXP (note, 0), oldreg, newval);
+ XEXP (note, 0) = simplify_replace_rtx (XEXP (note, 0), oldreg, newval);
insn = end;
}
return true;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f6f3bde..eebb2e8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-29 Roger Sayle <roger@eyesopen.com>
+
+ PR rtl-optimization/17581
+ * gcc.dg/pr17581-1.c: New test case.
+
2004-10-28 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/conversion/dr195.C: Adjust expected errors for DR195 not
diff --git a/gcc/testsuite/gcc.dg/pr17581-1.c b/gcc/testsuite/gcc.dg/pr17581-1.c
new file mode 100644
index 0000000..757661e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr17581-1.c
@@ -0,0 +1,28 @@
+/* PR rtl-optimization/17581 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+int foo(int x)
+{
+ unsigned long long tmp = 0;
+
+ switch(x) {
+ case 21:
+ tmp |= 1;
+ tmp |= 2;
+ tmp |= 8;
+ break;
+ default:
+ break;
+ }
+
+ return (int)tmp;
+}
+
+int main()
+{
+ if (foo(21) != 11)
+ abort ();
+ return 0;
+}
+