From 7a6b7528533ea6d23a5b1a5624b4f68faf079a38 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 3 Sep 2005 20:49:51 +0200 Subject: [PATCH] re PR rtl-optimization/23454 (ICE in invert_exp_1, at jump.c:1719) PR rtl-optimization/23454 * reorg.c (relax_delay_slots): Only call invert_jump if any_condjump_p is true. * g++.dg/opt/pr23454.C: New test. From-SVN: r103810 --- gcc/ChangeLog | 6 +++++ gcc/reorg.c | 7 ++--- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/opt/pr23454.C | 41 ++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/opt/pr23454.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b488faa1ff..8bbb5bac372 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-09-03 Jakub Jelinek + + PR rtl-optimization/23454 + * reorg.c (relax_delay_slots): Only call invert_jump if any_condjump_p + is true. + 2005-09-03 Richard Henderson John David Anglin diff --git a/gcc/reorg.c b/gcc/reorg.c index cda716887d6..8b9d7efccfb 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -3123,10 +3123,11 @@ relax_delay_slots (rtx first) if (target_label && target_label != JUMP_LABEL (insn)) reorg_redirect_jump (insn, target_label); - /* See if this jump branches around an unconditional jump. - If so, invert this jump and point it to the target of the + /* See if this jump conditionally branches around an unconditional + jump. If so, invert this jump and point it to the target of the second jump. */ if (next && JUMP_P (next) + && any_condjump_p (insn) && (simplejump_p (next) || GET_CODE (PATTERN (next)) == RETURN) && target_label && next_active_insn (target_label) == next_active_insn (next) @@ -3172,7 +3173,7 @@ relax_delay_slots (rtx first) if (JUMP_P (insn) && (simplejump_p (insn) || GET_CODE (PATTERN (insn)) == RETURN) && (other = prev_active_insn (insn)) != 0 - && (condjump_p (other) || condjump_in_parallel_p (other)) + && any_condjump_p (other) && no_labels_between_p (other, insn) && 0 > mostly_true_jump (other, get_branch_condition (other, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0abc44f94f1..496ecc3c2ce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-03 Jakub Jelinek + + PR rtl-optimization/23454 + * g++.dg/opt/pr23454.C: New test. + 2005-09-03 Mark Mitchell PR c++/23699 diff --git a/gcc/testsuite/g++.dg/opt/pr23454.C b/gcc/testsuite/g++.dg/opt/pr23454.C new file mode 100644 index 00000000000..ab82b1f9b5f --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr23454.C @@ -0,0 +1,41 @@ +/* PR rtl-optimization/23454 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void foo (); +int a, b; +char c; +long long d, e; + +static inline int +bar (const long long s, const long long t) +{ + return ((s < t) ? -1 : s > t ? 1 : 0); +} + +int fn (); +int f; + +void +baz (int x) +{ + long long g = fn (); + if (f) + { + b++; + return; + } + if (g == 0) + a++; + if (x) + foo (); + if (!c) + c = 1; + else if (g != 0) + { + if (bar (g, d) < 0) + d = g; + if (bar (g, e) > 0) + e = g; + } +}