Fix load fusion in combination with depended register spill load

This commit is contained in:
Dmitry Stogov 2023-01-19 13:39:29 +03:00
parent a85f59a62d
commit 5103c18269
2 changed files with 3 additions and 2 deletions

View File

@ -564,6 +564,7 @@ int ir_compute_live_ranges(ir_ctx *ctx)
do {
if (ctx->ir_base[input].op == IR_LOAD) {
input = ctx->ir_base[input].op2;
use_flags = IR_USE_MUST_BE_IN_REG;
if (input < 0 || ctx->rules[input] != IR_SKIP_MEM) {
break;
}

View File

@ -1956,14 +1956,14 @@ static int32_t ir_fuse_load(ir_ctx *ctx, ir_ref ref, ir_reg *preg)
if (!IR_IS_CONST_REF(load_insn->op2)
&& ir_rule(ctx, load_insn->op2) != IR_SKIP_MEM) {
/* just fuse the LOAD itself */
if (*preg != IR_REG_NONE) {
if (*preg != IR_REG_NONE && *preg != ctx->regs[load_insn->op2][0]) {
IR_ASSERT(!((*preg) & IR_REG_SPILL_LOAD));
} else {
ir_reg reg = ctx->regs[load_insn->op2][0];
IR_ASSERT(reg != IR_REG_NONE);
if (reg & IR_REG_SPILL_LOAD) {
reg &= ~IR_REG_SPILL_LOAD;
ir_emit_load(ctx, load_insn->type, reg, load_insn->op2);
ir_emit_load(ctx, IR_ADDR, reg, load_insn->op2);
}
*preg = reg;
}