From e884e045de7809f8d826dfb7703371a7b7536a47 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 16 Dec 2022 13:38:58 +0300 Subject: [PATCH] Avoid zero extension to the same register --- ir_x86.dasc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ir_x86.dasc b/ir_x86.dasc index b001a1f..14c7bb1 100644 --- a/ir_x86.dasc +++ b/ir_x86.dasc @@ -4308,7 +4308,10 @@ static void ir_emit_zext(ir_ctx *ctx, ir_ref def, ir_insn *insn) IR_ASSERT(ir_type_size[dst_type] == 8); IR_ASSERT(sizeof(void*) == 8); |.if X64 - | mov Rd(def_reg), Rd(op1_reg) + /* Avoid zero extension to the same register. This may be not always safe ??? */ + if (op1_reg != def_reg) { + | mov Rd(def_reg), Rd(op1_reg) + } |.endif } } else if (IR_IS_CONST_REF(insn->op1)) {