Make licm_add_loop_preheaders returning true if a new BB is created.
Enumerate bbs if a new block is created in LICM.
@@ -2292,22 +2292,26 @@ static void create_preheader_from_edge (gen_ctx_t gen_ctx, edge_t e, loop_node_t
loop->preheader = new_bb;
}
-static void licm_add_loop_preheaders (gen_ctx_t gen_ctx, loop_node_t loop) {
+static int licm_add_loop_preheaders (gen_ctx_t gen_ctx, loop_node_t loop) {
bb_insn_t bb_insn;
edge_t e;
+ int new_bb_p = FALSE;
for (loop_node_t node = DLIST_HEAD (loop_node_t, loop->children); node != NULL;
node = DLIST_NEXT (loop_node_t, node))
if (node->bb == NULL) /* process sub-loops */
- licm_add_loop_preheaders (gen_ctx, node);
- if (loop == curr_cfg->root_loop_node) return;
+ new_bb_p = licm_add_loop_preheaders (gen_ctx, node) || new_bb_p;
+ if (loop == curr_cfg->root_loop_node) return new_bb_p;
loop->preheader = NULL;
- if ((e = find_loop_entry_edge (gen_ctx, loop->entry->bb)) == NULL) return;
+ if ((e = find_loop_entry_edge (gen_ctx, loop->entry->bb)) == NULL) return new_bb_p;
if ((bb_insn = DLIST_TAIL (bb_insn_t, e->src->bb_insns)) == NULL
|| !MIR_branch_code_p (bb_insn->insn->code))
loop->preheader = e->src; /* The preheader already exists */
- else
+ else {
create_preheader_from_edge (gen_ctx, e, loop);
+ new_bb_p = TRUE;
+ }
+ return new_bb_p;
}
static void dom_con_func_0 (bb_t bb) { bitmap_clear (bb->dom_in); }
@@ -5646,7 +5650,7 @@ void *MIR_gen (MIR_context_t ctx, MIR_item_t func_item) {
#ifndef NO_LICM
if (optimize_level >= 3) {
if (build_loop_tree (gen_ctx)) {
- licm_add_loop_preheaders (gen_ctx, curr_cfg->root_loop_node);
+ if (licm_add_loop_preheaders (gen_ctx, curr_cfg->root_loop_node)) enumerate_bbs (gen_ctx);
calculate_reaching_defs (gen_ctx);
DEBUG ({ fprintf (debug_file, "+++++++++++++LICM:\n"); });
licm (gen_ctx);
