aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-01-11 20:05:34 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2004-01-11 20:05:34 +0100
commit1759c760db915101087a28efb4329fa6490eaef8 (patch)
treef8df1ff5a1cf6f5e7d38cc52a45a081d1bab8229 /gcc
parentb74a685105cac1e0f92628a8f8db16dbc84619b2 (diff)
downloadgcc-1759c760db915101087a28efb4329fa6490eaef8.zip
gcc-1759c760db915101087a28efb4329fa6490eaef8.tar.gz
gcc-1759c760db915101087a28efb4329fa6490eaef8.tar.bz2
re PR middle-end/13392 (ICE in convert_from_eh_region_ranges_1, at except.c:1133)
PR middle-end/13392 * builtins.c (expand_builtin_expect_jump): Handle conditional jumps to drop through label. Don't fall back to SCC even when conditional jump has not been found. * g++.dg/opt/expect2.C: New test. From-SVN: r75684
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/builtins.c46
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/opt/expect2.C11
4 files changed, 34 insertions, 35 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index aa162c6..1904cf6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2004-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/13392
+ * builtins.c (expand_builtin_expect_jump): Handle conditional jumps
+ to drop through label. Don't fall back to SCC even when conditional
+ jump has not been found.
+
2004-01-11 Jan Hubicka <jh@suse.cz>
* invoke.texi: Fix syntax error in previous patch.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 2660396..10c753b 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4441,39 +4441,24 @@ expand_builtin_expect_jump (tree exp, rtx if_false_label, rtx if_true_label)
if (TREE_CODE (TREE_TYPE (arg1)) == INTEGER_TYPE
&& (integer_zerop (arg1) || integer_onep (arg1)))
{
- int num_jumps = 0;
- int save_pending_stack_adjust = pending_stack_adjust;
- rtx insn;
-
- /* If we fail to locate an appropriate conditional jump, we'll
- fall back to normal evaluation. Ensure that the expression
- can be re-evaluated. */
- switch (unsafe_for_reeval (arg0))
- {
- case 0: /* Safe. */
- break;
-
- case 1: /* Mildly unsafe. */
- arg0 = unsave_expr (arg0);
- break;
-
- case 2: /* Wildly unsafe. */
- return NULL_RTX;
- }
+ rtx insn, drop_through_label;
/* Expand the jump insns. */
start_sequence ();
do_jump (arg0, if_false_label, if_true_label);
ret = get_insns ();
+
+ drop_through_label = get_last_insn ();
+ if (drop_through_label && GET_CODE (drop_through_label) == NOTE)
+ drop_through_label = prev_nonnote_insn (drop_through_label);
+ if (drop_through_label && GET_CODE (drop_through_label) != CODE_LABEL)
+ drop_through_label = NULL_RTX;
end_sequence ();
- /* For mildly unsafe builtin jump's, if unsave_expr_now
- creates a new tree instead of changing the old one
- TREE_VALUE (arglist) needs to be updated. */
- if (arg0 != TREE_VALUE (arglist)
- && TREE_CODE (arg0) == UNSAVE_EXPR
- && TREE_OPERAND (arg0, 0) != TREE_VALUE (arglist))
- TREE_VALUE (arglist) = TREE_OPERAND (arg0, 0);
+ if (! if_true_label)
+ if_true_label = drop_through_label;
+ if (! if_false_label)
+ if_false_label = drop_through_label;
/* Now that the __builtin_expect has been validated, go through and add
the expect's to each of the conditional jumps. If we run into an
@@ -4531,21 +4516,12 @@ expand_builtin_expect_jump (tree exp, rtx if_false_label, rtx if_true_label)
else if (label != if_true_label)
goto do_next_insn;
- num_jumps++;
predict_insn_def (insn, PRED_BUILTIN_EXPECT, taken);
}
do_next_insn:
insn = next;
}
-
- /* If no jumps were modified, fail and do __builtin_expect the normal
- way. */
- if (num_jumps == 0)
- {
- ret = NULL_RTX;
- pending_stack_adjust = save_pending_stack_adjust;
- }
}
return ret;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2d7b506..4aa8241 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2004-01-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/13392
+ * g++.dg/opt/expect2.C: New test.
+
2004-01-10 Zack Weinberg <zack@codesourcery.com>
* gcc.dg/Wshadow-1.c, gcc.dg/attr-noinline.c, gcc.dg/decl3.c
diff --git a/gcc/testsuite/g++.dg/opt/expect2.C b/gcc/testsuite/g++.dg/opt/expect2.C
new file mode 100644
index 0000000..1bb5d83
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/expect2.C
@@ -0,0 +1,11 @@
+// PR c++/13392
+// { dg-do compile }
+// { dg-options "-O0" }
+
+extern "C" void abort (void);
+struct X { ~X () throw() {} };
+bool foo (X s = X ()) { return false; }
+void bar ()
+{
+ __builtin_expect (foo () && true, 1) ? 0 : (abort (), 0);
+}