diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54e7627562f3785977518115c73cc990f8d1a394..0ba93a4ef572493898615178a19ec31b134ffa47 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2000-05-19 Richard Henderson <rth@cygnus.com> + + * jump.c (redirect_jump): Add delete_unused argument. Don't + remove labels and code following when LABEL_NUSES goes to zero. + (invert_jump): Likewise. + (jump_optimize_1): Fix redirect/invert arguments. + (do_cross_jump, thread_jumps): Likewise. + * flow.c (split_edge): Likewise. + * reorg.c (optimize_skip): Likewise. + (reorg_redirect_jump, relax_delay_slots, dbr_schedule): Likewise. + * profile.c (instrument_arcs): Likewise. + * loop.c (find_and_verify_loops): Likewise. Fix indentation. + * rtl.h: Update prototypes. + Fri May 19 12:05:13 2000 Clinton Popetz <cpopetz@cygnus.com> * ssa.c (convert_from_ssa): Tell life_analysis we need death @@ -52,7 +66,7 @@ Fri May 19 06:49:35 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 2000-05-18 Mark Elbrecht <snowball3@bigfoot.com> - * configure.in (*-pc-msdosdjgpp): Set float_format to none. + * configure.in (*-pc-msdosdjgpp): Set float_format to none. * configure: Rebuilt. 2000-05-18 Zack Weinberg <zack@wolery.cumb.org> diff --git a/gcc/flow.c b/gcc/flow.c index e24822e8404522b71ee57fc72b166eccaac34867..e6d4bbbcbfa5f7f48a79f0d695d271059887c6c2 100644 --- a/gcc/flow.c +++ b/gcc/flow.c @@ -1556,7 +1556,7 @@ split_edge (edge_in) if (JUMP_LABEL (insn) != old_label) abort (); - redirect_jump (insn, new_label); + redirect_jump (insn, new_label, 0); } emit_label_before (new_label, bb_note); diff --git a/gcc/jump.c b/gcc/jump.c index 85bfb86a500a46f3fba59de050feb9982550bd4c..8711ba95efd3168f32f1c92a42d46be737a97cd5 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -342,7 +342,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, /* See if this jump goes to another jump and redirect if so. */ nlabel = follow_jumps (JUMP_LABEL (insn)); if (nlabel != JUMP_LABEL (insn)) - changed |= redirect_jump (insn, nlabel); + changed |= redirect_jump (insn, nlabel, 1); if (! optimize || minimal) continue; @@ -444,7 +444,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, if (prev_label) ++LABEL_NUSES (prev_label); - if (invert_jump (insn, JUMP_LABEL (reallabelprev))) + if (invert_jump (insn, JUMP_LABEL (reallabelprev), 1)) { /* It is very likely that if there are USE insns before this jump, they hold REG_DEAD notes. These REG_DEAD @@ -507,7 +507,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, } delete_insn (temp); - redirect_jump (insn, get_label_before (temp1)); + redirect_jump (insn, get_label_before (temp1), 1); reallabelprev = prev_real_insn (temp1); changed = 1; next = NEXT_INSN (insn); @@ -579,7 +579,7 @@ jump_optimize_1 (f, cross_jump, noop_moves, after_regscan, && swap_condition (GET_CODE (temp2)) == GET_CODE (tc) && rtx_equal_p (XEXP (tc, 0), XEXP (temp2, 0)) && rtx_equal_p (XEXP (tc, 1), XEXP (temp2, 1)) - && redirect_jump (insn, get_label_after (temp))) + && redirect_jump (insn, get_label_after (temp), 1)) { changed = 1; continue; @@ -1629,7 +1629,7 @@ do_cross_jump (insn, newjpos, newlpos) } } else - redirect_jump (insn, label); + redirect_jump (insn, label, 1); /* Delete the matching insns before the jump. Also, remove any REG_EQUAL or REG_EQUIV note in the NEWLPOS stream that isn't also present in @@ -3182,8 +3182,9 @@ redirect_jump_1 (jump, nlabel) (this can only occur for NLABEL == 0). */ int -redirect_jump (jump, nlabel) +redirect_jump (jump, nlabel, delete_unused) rtx jump, nlabel; + int delete_unused; { register rtx olabel = JUMP_LABEL (jump); @@ -3221,7 +3222,7 @@ redirect_jump (jump, nlabel) && NOTE_LINE_NUMBER (NEXT_INSN (olabel)) == NOTE_INSN_FUNCTION_END) emit_note_after (NOTE_INSN_FUNCTION_END, nlabel); - if (olabel && --LABEL_NUSES (olabel) == 0) + if (olabel && --LABEL_NUSES (olabel) == 0 && delete_unused) delete_insn (olabel); return 1; @@ -3321,8 +3322,9 @@ invert_jump_1 (jump, nlabel) NLABEL instead of where it jumps now. Return true if successful. */ int -invert_jump (jump, nlabel) +invert_jump (jump, nlabel, delete_unused) rtx jump, nlabel; + int delete_unused; { /* We have to either invert the condition and change the label or do neither. Either operation could fail. We first try to invert @@ -3332,7 +3334,7 @@ invert_jump (jump, nlabel) if (! invert_exp (PATTERN (jump), jump)) return 0; - if (redirect_jump (jump, nlabel)) + if (redirect_jump (jump, nlabel, delete_unused)) { /* An inverted jump means that a probability taken becomes a probability not taken. Subtract the branch probability from the @@ -3911,7 +3913,7 @@ thread_jumps (f, max_reg, flag_before_loop) new_label = gen_label_rtx (); emit_label_after (new_label, PREV_INSN (prev)); } - changed |= redirect_jump (b1, new_label); + changed |= redirect_jump (b1, new_label, 1); } break; } diff --git a/gcc/loop.c b/gcc/loop.c index 70c307ab82cbbbd74596c30ae9a30b78c64cf904..a8e71b715452770f652b4b7e0d850b3e4422a168 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -2865,86 +2865,86 @@ find_and_verify_loops (f, loops) /* Verify that uid_loop is large enough and that we can invert P. */ - if (invert_jump (p, new_label)) - { - rtx q, r; - - /* If no suitable BARRIER was found, create a suitable - one before TARGET. Since TARGET is a fall through - path, we'll need to insert an jump around our block - and a add a BARRIER before TARGET. - - This creates an extra unconditional jump outside - the loop. However, the benefits of removing rarely - executed instructions from inside the loop usually - outweighs the cost of the extra unconditional jump - outside the loop. */ - if (loc == 0) - { - rtx temp; - - temp = gen_jump (JUMP_LABEL (insn)); - temp = emit_jump_insn_before (temp, target); - JUMP_LABEL (temp) = JUMP_LABEL (insn); - LABEL_NUSES (JUMP_LABEL (insn))++; - loc = emit_barrier_before (target); - } - - /* Include the BARRIER after INSN and copy the - block after LOC. */ - new_label = squeeze_notes (new_label, - last_insn_to_move); - reorder_insns (new_label, last_insn_to_move, loc); - - /* All those insns are now in TARGET_LOOP. */ - for (q = new_label; - q != NEXT_INSN (last_insn_to_move); - q = NEXT_INSN (q)) - uid_loop[INSN_UID (q)] = target_loop; - - /* The label jumped to by INSN is no longer a loop exit. - Unless INSN does not have a label (e.g., it is a - RETURN insn), search loop->exit_labels to find - its label_ref, and remove it. Also turn off - LABEL_OUTSIDE_LOOP_P bit. */ - if (JUMP_LABEL (insn)) - { - for (q = 0, - r = this_loop->exit_labels; - r; q = r, r = LABEL_NEXTREF (r)) - if (XEXP (r, 0) == JUMP_LABEL (insn)) - { - LABEL_OUTSIDE_LOOP_P (r) = 0; - if (q) - LABEL_NEXTREF (q) = LABEL_NEXTREF (r); - else - this_loop->exit_labels = LABEL_NEXTREF (r); - break; - } - - for (loop = this_loop; loop && loop != target_loop; - loop = loop->outer) - loop->exit_count--; - - /* If we didn't find it, then something is - wrong. */ - if (! r) - abort (); - } - - /* P is now a jump outside the loop, so it must be put - in loop->exit_labels, and marked as such. - The easiest way to do this is to just call - mark_loop_jump again for P. */ - mark_loop_jump (PATTERN (p), this_loop); - - /* If INSN now jumps to the insn after it, - delete INSN. */ - if (JUMP_LABEL (insn) != 0 - && (next_real_insn (JUMP_LABEL (insn)) - == next_real_insn (insn))) - delete_insn (insn); - } + if (invert_jump (p, new_label, 1)) + { + rtx q, r; + + /* If no suitable BARRIER was found, create a suitable + one before TARGET. Since TARGET is a fall through + path, we'll need to insert an jump around our block + and a add a BARRIER before TARGET. + + This creates an extra unconditional jump outside + the loop. However, the benefits of removing rarely + executed instructions from inside the loop usually + outweighs the cost of the extra unconditional jump + outside the loop. */ + if (loc == 0) + { + rtx temp; + + temp = gen_jump (JUMP_LABEL (insn)); + temp = emit_jump_insn_before (temp, target); + JUMP_LABEL (temp) = JUMP_LABEL (insn); + LABEL_NUSES (JUMP_LABEL (insn))++; + loc = emit_barrier_before (target); + } + + /* Include the BARRIER after INSN and copy the + block after LOC. */ + new_label = squeeze_notes (new_label, + last_insn_to_move); + reorder_insns (new_label, last_insn_to_move, loc); + + /* All those insns are now in TARGET_LOOP. */ + for (q = new_label; + q != NEXT_INSN (last_insn_to_move); + q = NEXT_INSN (q)) + uid_loop[INSN_UID (q)] = target_loop; + + /* The label jumped to by INSN is no longer a loop + exit. Unless INSN does not have a label (e.g., + it is a RETURN insn), search loop->exit_labels + to find its label_ref, and remove it. Also turn + off LABEL_OUTSIDE_LOOP_P bit. */ + if (JUMP_LABEL (insn)) + { + for (q = 0, + r = this_loop->exit_labels; + r; q = r, r = LABEL_NEXTREF (r)) + if (XEXP (r, 0) == JUMP_LABEL (insn)) + { + LABEL_OUTSIDE_LOOP_P (r) = 0; + if (q) + LABEL_NEXTREF (q) = LABEL_NEXTREF (r); + else + this_loop->exit_labels = LABEL_NEXTREF (r); + break; + } + + for (loop = this_loop; loop && loop != target_loop; + loop = loop->outer) + loop->exit_count--; + + /* If we didn't find it, then something is + wrong. */ + if (! r) + abort (); + } + + /* P is now a jump outside the loop, so it must be put + in loop->exit_labels, and marked as such. + The easiest way to do this is to just call + mark_loop_jump again for P. */ + mark_loop_jump (PATTERN (p), this_loop); + + /* If INSN now jumps to the insn after it, + delete INSN. */ + if (JUMP_LABEL (insn) != 0 + && (next_real_insn (JUMP_LABEL (insn)) + == next_real_insn (insn))) + delete_insn (insn); + } /* Continue the loop after where the conditional branch used to jump, since the only branch insn diff --git a/gcc/profile.c b/gcc/profile.c index d8e2d62e62a8ad8b177275a2d66d0ea18f87a046..69ac575168d9b5cbfab965c026d0bd16f07eec4c 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -293,14 +293,14 @@ instrument_arcs (f, num_blocks, dump_file) if (this_is_simplejump) { after = NEXT_INSN (arcptr->branch_insn); - if (! redirect_jump (arcptr->branch_insn, new_label)) + if (! redirect_jump (arcptr->branch_insn, new_label, 1)) /* Don't know what to do if this branch won't redirect. */ abort (); } else { - if (! invert_jump (arcptr->branch_insn, new_label)) + if (! invert_jump (arcptr->branch_insn, new_label, 1)) /* Don't know what to do if this branch won't invert. */ abort (); diff --git a/gcc/reorg.c b/gcc/reorg.c index cce40c0d7cf46b79d32cdd6c4ff6a2bf1bdbced0..e5c58873aa25bc463263164e8c859f3068929d22 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -733,7 +733,7 @@ optimize_skip (insn) { if (eligible_for_annul_false (insn, 0, trial, flags)) { - if (invert_jump (insn, JUMP_LABEL (insn))) + if (invert_jump (insn, JUMP_LABEL (insn), 1)) INSN_FROM_TARGET_P (trial) = 1; else if (! eligible_for_annul_true (insn, 0, trial, flags)) return 0; @@ -1888,7 +1888,7 @@ reorg_redirect_jump (jump, nlabel) rtx nlabel; { incr_ticks_for_insn (jump); - return redirect_jump (jump, nlabel); + return redirect_jump (jump, nlabel, 1); } /* Called when INSN is being moved forward into a delay slot of DELAYED_INSN. @@ -3087,7 +3087,7 @@ relax_delay_slots (first) if (label) ++LABEL_NUSES (label); - if (invert_jump (insn, label)) + if (invert_jump (insn, label, 1)) { delete_insn (next); next = insn; @@ -3123,16 +3123,8 @@ relax_delay_slots (first) rtx other_target = JUMP_LABEL (other); target_label = JUMP_LABEL (insn); - /* Increment the count of OTHER_TARGET, so it doesn't get deleted - as we move the label. */ - if (other_target) - ++LABEL_NUSES (other_target); - - if (invert_jump (other, target_label)) + if (invert_jump (other, target_label, 0)) reorg_redirect_jump (insn, other_target); - - if (other_target) - --LABEL_NUSES (other_target); } /* Now look only at cases where we have filled a delay slot. */ @@ -3338,7 +3330,7 @@ relax_delay_slots (first) if (old_label) ++LABEL_NUSES (old_label); - if (invert_jump (delay_insn, label)) + if (invert_jump (delay_insn, label, 1)) { int i; @@ -3570,7 +3562,7 @@ dbr_schedule (first, file) && JUMP_LABEL (insn) != 0 && ((target = prev_label (next_active_insn (JUMP_LABEL (insn)))) != JUMP_LABEL (insn))) - redirect_jump (insn, target); + redirect_jump (insn, target, 1); } init_resource_info (epilogue_insn); diff --git a/gcc/rtl.h b/gcc/rtl.h index 4ab7407f335d013c9edad762c44358132979ee82..de088179e521f7b4b28f859c2df251baa7638bbc 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1522,11 +1522,11 @@ extern int returnjump_p PARAMS ((rtx)); extern int onlyjump_p PARAMS ((rtx)); extern int sets_cc0_p PARAMS ((rtx)); extern int invert_jump_1 PARAMS ((rtx, rtx)); -extern int invert_jump PARAMS ((rtx, rtx)); +extern int invert_jump PARAMS ((rtx, rtx, int)); extern int rtx_renumbered_equal_p PARAMS ((rtx, rtx)); extern int true_regnum PARAMS ((rtx)); extern int redirect_jump_1 PARAMS ((rtx, rtx)); -extern int redirect_jump PARAMS ((rtx, rtx)); +extern int redirect_jump PARAMS ((rtx, rtx, int)); extern void jump_optimize PARAMS ((rtx, int, int, int)); extern void jump_optimize_minimal PARAMS ((rtx)); extern void rebuild_jump_labels PARAMS ((rtx));