From: Richard Henderson Date: Sat, 21 Jul 2001 03:05:09 +0000 (-0700) Subject: flow.c (try_redirect_by_replacing_jump): Correctly compute which insns to delete... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e9644cfea18acae1d77d30b608bde9f5c5f6e602;p=gcc.git flow.c (try_redirect_by_replacing_jump): Correctly compute which insns to delete in the presence of cc0 in a jump insn. * flow.c (try_redirect_by_replacing_jump): Correctly compute which insns to delete in the presence of cc0 in a jump insn. From-SVN: r44217 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e23305a8194..4f6c91979ff 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,9 @@ * doc/rtl.texi (REG_DEAD): Update for current semantics. + * flow.c (try_redirect_by_replacing_jump): Correctly compute which + insns to delete in the presence of cc0 in a jump insn. + Fri Jul 20 22:14:49 CEST 2001 Roman Zippel Jan Hubicka diff --git a/gcc/flow.c b/gcc/flow.c index 06a10401f79..fb054e4b411 100644 --- a/gcc/flow.c +++ b/gcc/flow.c @@ -1654,7 +1654,7 @@ try_redirect_by_replacing_jump (e, target) basic_block target; { basic_block src = e->src; - rtx insn = src->end; + rtx insn = src->end, kill_from; edge tmp; rtx set; int fallthru = 0; @@ -1671,19 +1671,24 @@ try_redirect_by_replacing_jump (e, target) if (!set || side_effects_p (set)) return false; + /* In case we zap a conditional jump, we'll need to kill + the cc0 setter too. */ + kill_from = insn; +#ifdef HAVE_cc0 + if (reg_mentioned_p (cc0_rtx, PATTERN (insn))) + kill_from = PREV_INSN (insn); +#endif + /* See if we can create the fallthru edge. */ if (can_fallthru (src, target)) { - src->end = PREV_INSN (insn); + src->end = PREV_INSN (kill_from); if (rtl_dump_file) fprintf (rtl_dump_file, "Removing jump %i.\n", INSN_UID (insn)); - flow_delete_insn (insn); fallthru = 1; /* Selectivly unlink whole insn chain. */ - if (src->end != PREV_INSN (target->head)) - flow_delete_insn_chain (NEXT_INSN (src->end), - PREV_INSN (target->head)); + flow_delete_insn_chain (kill_from, PREV_INSN (target->head)); } /* If this already is simplejump, redirect it. */ else if (simplejump_p (insn)) @@ -1701,8 +1706,7 @@ try_redirect_by_replacing_jump (e, target) rtx target_label = block_label (target); rtx barrier; - src->end = PREV_INSN (insn); - src->end = emit_jump_insn_after (gen_jump (target_label), src->end); + src->end = emit_jump_insn_before (gen_jump (target_label), kill_from); JUMP_LABEL (src->end) = target_label; LABEL_NUSES (target_label)++; if (basic_block_for_insn) @@ -1710,7 +1714,9 @@ try_redirect_by_replacing_jump (e, target) if (rtl_dump_file) fprintf (rtl_dump_file, "Replacing insn %i by jump %i\n", INSN_UID (insn), INSN_UID (src->end)); - flow_delete_insn (insn); + + flow_delete_insn_chain (kill_from, insn); + barrier = next_nonnote_insn (src->end); if (!barrier || GET_CODE (barrier) != BARRIER) emit_barrier_after (src->end); @@ -1727,20 +1733,6 @@ try_redirect_by_replacing_jump (e, target) e->probability = REG_BR_PROB_BASE; e->count = src->count; - /* In case we've zapped an conditional jump, we need to kill the cc0 - setter too if available. */ -#ifdef HAVE_cc0 - insn = src->end; - if (GET_CODE (insn) == JUMP_INSN) - insn = prev_nonnote_insn (insn); - if (sets_cc0_p (insn)) - { - if (insn == src->end) - src->end = PREV_INSN (insn); - flow_delete_insn (insn); - } -#endif - /* We don't want a block to end on a line-number note since that has the potential of changing the code between -g and not -g. */ while (GET_CODE (e->src->end) == NOTE