This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Cleanup unconditional jumps and forwarder blocks before reordering
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, patches at x86-64 dot org
- Subject: Cleanup unconditional jumps and forwarder blocks before reordering
- From: Jan Hubicka <jh at suse dot cz>
- Date: Thu, 30 Aug 2001 15:29:47 +0200
Hi,
this patch adds function to kill unconditional jumps and forwarder blocks
in the bb-reroder CFG representation as disucssed earlier. It simplifies
future algorithm for better graph layout and slightly improves current one
as well - it should also make the cfg_cleanup after reordering obsolette
except for BB merging, but I first want to do more testing first.
Regtested/bootstrapped i686 togeter with other today patches, testing
Sparc and PPC in meantime.
Thu Aug 30 15:27:07 CEST 2001 Jan Hubicka <jh@suse.cz>
* bb-reorder.c (cleanup_unconditional_jumps): New function.
(reorder_basic_blocks): Use it.
*** bb-reorder.c.orig Sun Aug 5 17:58:25 2001
--- bb-reorder.c Thu Aug 30 15:06:34 2001
*************** static rtx get_next_bb_note PARAMS ((rt
*** 196,201 ****
--- 199,273 ----
static rtx get_prev_bb_note PARAMS ((rtx));
void verify_insn_chain PARAMS ((void));
+ static void cleanup_unconditional_jumps PARAMS ((void));
+
+ /* Remove any unconditional jumps and forwarder block creating fallthru
+ edges instead. During BB reordering fallthru edges are not required
+ to target next basic block in the linear CFG layout, so the unconditional
+ jumps are not needed. */
+
+
+ static void
+ cleanup_unconditional_jumps ()
+ {
+ int i;
+ for (i = 0; i < n_basic_blocks; i++)
+ {
+ basic_block bb = BASIC_BLOCK (i);
+
+ if (!bb->succ)
+ continue;
+ if (bb->succ->flags & EDGE_FALLTHRU)
+ continue;
+ if (!bb->succ->succ_next)
+ {
+ rtx insn;
+ if (GET_CODE (bb->head) != CODE_LABEL && forwarder_block_p (bb))
+ {
+ basic_block prev = BASIC_BLOCK (--i);
+
+ if (rtl_dump_file)
+ fprintf (rtl_dump_file, "Removing forwarder BB %i\n",
+ bb->index);
+
+ redirect_edge_succ (bb->pred, bb->succ->dest);
+ flow_delete_block (bb);
+ bb = prev;
+ }
+ else if (simplejump_p (bb->end))
+ {
+ rtx jump = bb->end;
+ bb->end = PREV_INSN (jump);
+ if (rtl_dump_file)
+ fprintf (rtl_dump_file, "Removing jump %i in BB %i\n",
+ INSN_UID (jump), bb->index);
+ flow_delete_insn (jump);
+ bb->succ->flags |= EDGE_FALLTHRU;
+ }
+ else
+ continue;
+
+ /* Cleanup barriers and verify that there are no tablejumps
+ in a way. */
+ insn = NEXT_INSN (bb->end);
+ while (insn
+ && (GET_CODE (insn) != NOTE
+ || NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK))
+ {
+ rtx next = NEXT_INSN (insn);
+
+ if (GET_CODE (insn) == BARRIER)
+ delete_barrier (insn);
+ else if (GET_CODE (insn) == CODE_LABEL)
+ ;
+ else if (GET_CODE (insn) != NOTE)
+ abort ();
+
+ insn = next;
+ }
+ }
+ }
+ }
/* Skip over inter-block insns occurring after BB which are typically
associated with BB (e.g., barriers). If there are any such insns,
*************** reorder_basic_blocks ()
*** 1393,1400 ****
build_scope_forest (&forest);
remove_scope_notes ();
!
record_effective_endpoints ();
make_reorder_chain ();
fixup_reorder_chain ();
--- 1759,1766 ----
build_scope_forest (&forest);
remove_scope_notes ();
! cleanup_unconditional_jumps ();
record_effective_endpoints ();
make_reorder_chain ();
fixup_reorder_chain ();