Set ir_ctx.prev_ref[] elements for inner BB traversing

This commit is contained in:
Dmitry Stogov 2022-11-23 16:16:08 +03:00
parent b94f907907
commit bdb8e6a1da
2 changed files with 3 additions and 2 deletions

View File

@ -270,11 +270,11 @@ int ir_match(ir_ctx *ctx)
if (!ctx->prev_ref) {
ctx->prev_ref = ir_mem_malloc(ctx->insns_count * sizeof(ir_ref));
prev = 0;
for (b = 1, bb = ctx->cfg_blocks + b; b <= ctx->cfg_blocks_count; b++, bb++) {
if (bb->flags & IR_BB_UNREACHABLE) {
continue;
}
prev = 0;
for (i = bb->start, insn = ctx->ir_base + i; i < bb->end;) {
ctx->prev_ref[i] = prev;
n = ir_operands_count(ctx, insn);

View File

@ -57,6 +57,7 @@ int ir_assign_virtual_registers(ir_ctx *ctx)
}
vregs = ir_mem_calloc(ctx->insns_count, sizeof(ir_ref));
n = 1;
prev = 0;
for (b = 1, bb = ctx->cfg_blocks + b; b <= ctx->cfg_blocks_count; b++, bb++) {
if (bb->flags & IR_BB_UNREACHABLE) {
continue;
@ -65,7 +66,7 @@ int ir_assign_virtual_registers(ir_ctx *ctx)
/* skip first instruction */
insn = ctx->ir_base + i;
ctx->prev_ref[i] = 0;
ctx->prev_ref[i] = prev;
prev = i;
n = ir_operands_count(ctx, insn);
n = 1 + (n >> 2); // support for multi-word instructions like MERGE and PHI