Skip to content

Commit

Permalink
Avoid LICM if LOOP doesn't have a pre-header block (has few forward i…
Browse files Browse the repository at this point in the history
…nput edges)
  • Loading branch information
dstogov committed Oct 17, 2024
1 parent 88c71c9 commit abbdbf2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ir_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ static uint32_t ir_gcm_select_best_block(ir_ctx *ctx, ir_ref ref, uint32_t lca)
bb = &ctx->cfg_blocks[b];
if (bb->loop_depth < loop_depth) {
if (!bb->loop_depth) {
#if 1
/* Avoid LICM if LOOP doesn't have a pre-header block */
ir_block *loop_bb = &ctx->cfg_blocks[best];

if (!(loop_bb->flags & IR_BB_LOOP_HEADER)) {
loop_bb = &ctx->cfg_blocks[loop_bb->loop_header];
}
if (loop_bb->predecessors_count > 2) {
int n = loop_bb->predecessors_count;
uint32_t *p = ctx->cfg_edges + loop_bb->predecessors;

while (n && *p != b) {
n--; p++;
}
if (!n) {
break;
}
}
#endif
best = b;
break;
}
Expand Down

0 comments on commit abbdbf2

Please sign in to comment.