From d9e21e00a874228c37a1212290133b16f684e0a1 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sun, 11 Jan 2004 20:13:12 +0100 Subject: [PATCH] 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: r75687 --- gcc/ChangeLog | 7 +++++++ gcc/builtins.c | 42 +++++++++++------------------------------ gcc/testsuite/ChangeLog | 5 +++++ 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 823b3a9c8684..bce807211aaa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2004-01-11 Jakub Jelinek + + 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-09 Jeff Bailey PR target/12561 diff --git a/gcc/builtins.c b/gcc/builtins.c index c82165f44595..55ef544d3f54 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -3663,38 +3663,24 @@ expand_builtin_expect_jump (exp, if_false_label, if_true_label) if (TREE_CODE (TREE_TYPE (arg1)) == INTEGER_TYPE && (integer_zerop (arg1) || integer_onep (arg1))) { - int num_jumps = 0; - 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 @@ -3757,18 +3743,12 @@ expand_builtin_expect_jump (exp, if_false_label, 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; } return ret; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9994585c0777..f60b1c350381 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-01-11 Jakub Jelinek + + PR middle-end/13392 + * g++.dg/opt/expect2.C: New test. + 2004-01-02 Matthias Klose Backport from mainline: -- 2.47.2