From c7e2cca5344f1da1e7dece181ed2a4521aa19844 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 15 Feb 2023 18:33:02 +0300 Subject: [PATCH] Add hint to reuse register in ZEXT/SEXT --- ir_ra.c | 3 +-- ir_x86.dasc | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ir_ra.c b/ir_ra.c index db334da..65b7855 100644 --- a/ir_ra.c +++ b/ir_ra.c @@ -513,8 +513,7 @@ int ir_compute_live_ranges(ir_ctx *ctx) /* We add two uses to emulate move from op1 to res */ ir_add_use(ctx, ctx->vregs[ref], 0, IR_DEF_LIVE_POS_FROM_REF(ref), reg, def_flags, 0); def_pos = IR_LOAD_LIVE_POS_FROM_REF(ref); - if (!IR_IS_CONST_REF(insn->op1)) { - IR_ASSERT(ctx->vregs[insn->op1]); + if (!IR_IS_CONST_REF(insn->op1) && ctx->vregs[insn->op1]) { hint_ref = insn->op1; } } else if (def_flags & IR_DEF_CONFLICTS_WITH_INPUT_REGS) { diff --git a/ir_x86.dasc b/ir_x86.dasc index 528157e..febb32e 100644 --- a/ir_x86.dasc +++ b/ir_x86.dasc @@ -814,8 +814,6 @@ cmp_fp: flags = IR_DEF_REUSES_OP1_REG | IR_USE_MUST_BE_IN_REG | IR_OP1_MUST_BE_IN_REG | IR_OP2_SHOULD_BE_IN_REG; break; case IR_SHIFT_CONST: - case IR_COPY_INT: - case IR_COPY_FP: case IR_INC: case IR_DEC: case IR_MUL_PWR2: @@ -825,6 +823,12 @@ cmp_fp: case IR_OP_FP: flags = IR_DEF_REUSES_OP1_REG | IR_USE_MUST_BE_IN_REG | IR_OP1_MUST_BE_IN_REG; break; + case IR_COPY_INT: + case IR_COPY_FP: + case IR_SEXT: + case IR_ZEXT: + flags = IR_DEF_REUSES_OP1_REG | IR_USE_MUST_BE_IN_REG | IR_OP1_SHOULD_BE_IN_REG; + break; case IR_ABS_INT: flags = IR_DEF_CONFLICTS_WITH_INPUT_REGS | IR_USE_MUST_BE_IN_REG | IR_OP1_MUST_BE_IN_REG; break;