aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2010-06-09 21:49:44 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-06-09 21:49:44 +0000
commit642d55de0e40c7bf59ab0043aeae756f004488dc (patch)
tree94bae21be77c1e10d071c24ca7c48b99738ab87d
parent70987f6299983c5a764c37827a95f71f831087f0 (diff)
downloadgcc-642d55de0e40c7bf59ab0043aeae756f004488dc.zip
gcc-642d55de0e40c7bf59ab0043aeae756f004488dc.tar.gz
gcc-642d55de0e40c7bf59ab0043aeae756f004488dc.tar.bz2
re PR rtl-optimization/42461 (missed optimization for pure functions)
PR rtl-optimization/42461 * dce.c (deletable_insn_p): Return true for const or pure calls again. * except.c (insn_could_throw_p): Return false if !flag_exceptions. From-SVN: r160507
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/dce.c16
-rw-r--r--gcc/except.c2
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/pr42461.c14
5 files changed, 36 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8c322d0..409e3ca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR rtl-optimization/42461
+ * dce.c (deletable_insn_p): Return true for const or pure calls again.
+ * except.c (insn_could_throw_p): Return false if !flag_exceptions.
+
2010-06-09 Jan Hubicka <jh@suse.cz>
* bitmap.c (bitmap_and): Walk array forward.
diff --git a/gcc/dce.c b/gcc/dce.c
index 38a5b30..ee18b58 100644
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -94,14 +94,6 @@ deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
rtx body, x;
int i;
- /* Don't delete jumps, notes and the like. */
- if (!NONJUMP_INSN_P (insn))
- return false;
-
- /* Don't delete insns that can throw. */
- if (!insn_nothrow_p (insn))
- return false;
-
if (CALL_P (insn)
/* We cannot delete calls inside of the recursive dce because
this may cause basic blocks to be deleted and this messes up
@@ -116,6 +108,14 @@ deletable_insn_p (rtx insn, bool fast, bitmap arg_stores)
&& !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
return find_call_stack_args (insn, false, fast, arg_stores);
+ /* Don't delete jumps, notes and the like. */
+ if (!NONJUMP_INSN_P (insn))
+ return false;
+
+ /* Don't delete insns that can throw. */
+ if (!insn_nothrow_p (insn))
+ return false;
+
body = PATTERN (insn);
switch (GET_CODE (body))
{
diff --git a/gcc/except.c b/gcc/except.c
index cb4d805..16a0247 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -1617,6 +1617,8 @@ make_reg_eh_region_note_nothrow_nononlocal (rtx insn)
bool
insn_could_throw_p (const_rtx insn)
{
+ if (!flag_exceptions)
+ return false;
if (CALL_P (insn))
return true;
if (INSN_P (insn) && cfun->can_throw_non_call_exceptions)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d0154a9..1f4d552 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,7 +1,11 @@
+2010-06-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc.dg/pr42461.c: New test.
+
2010-06-09 Daniel Franke <franke.daniel@gmail.com>
- PR fortran/44347
- * gfortran.dg/selected_real_kind_1.f90: New.
+ PR fortran/44347
+ * gfortran.dg/selected_real_kind_1.f90: New.
2010-06-09 Daniel Franke <franke.daniel@gmail.com>
diff --git a/gcc/testsuite/gcc.dg/pr42461.c b/gcc/testsuite/gcc.dg/pr42461.c
new file mode 100644
index 0000000..9d23ad9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr42461.c
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/42461 */
+/* Reported by Patrick Pelissier <patrick.pelissier@gmail.com> */
+
+/* { dg-do link } */
+/* { dg-options "-O" } */
+
+extern int link_failure (int) __attribute__ ((pure));
+
+int main (void)
+{
+ if (link_failure (0) < 1)
+ __builtin_unreachable ();
+ return 0;
+}