diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs index 19e604a2f8..d52ed265bd 100644 --- a/yjit/src/backend/x86_64/mod.rs +++ b/yjit/src/backend/x86_64/mod.rs @@ -181,6 +181,23 @@ impl Assembler iterator.map_insn_index(&mut asm); iterator.next_unmapped(); // Pop merged Insn::Mov } + (Opnd::Reg(_), Opnd::Reg(_), Some(Insn::Mov { dest, src })) + if out == src && live_ranges[index] == index + 1 && { + // We want to do `dest == left`, but `left` has already gone + // through lower_stack_opnd() while `dest` has not. So we + // lower `dest` before comparing. + let lowered_dest = if let Opnd::Stack { .. } = dest { + asm.lower_stack_opnd(dest) + } else { + *dest + }; + lowered_dest == *left + } => { + *out = *dest; + asm.push_insn(insn); + iterator.map_insn_index(&mut asm); + iterator.next_unmapped(); // Pop merged Insn::Mov + } _ => { match (unmapped_opnds[0], unmapped_opnds[1]) { (Opnd::Mem(_), Opnd::Mem(_)) => { diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index be719023c0..d60f4f0ec1 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -3827,7 +3827,7 @@ fn gen_opt_and( // Push the output on the stack let dst = asm.stack_push(Type::Fixnum); - asm.store(dst, val); + asm.mov(dst, val); Some(KeepCompiling) } else { @@ -3867,7 +3867,7 @@ fn gen_opt_or( // Push the output on the stack let dst = asm.stack_push(Type::Fixnum); - asm.store(dst, val); + asm.mov(dst, val); Some(KeepCompiling) } else { @@ -3909,7 +3909,7 @@ fn gen_opt_minus( // Push the output on the stack let dst = asm.stack_push(Type::Fixnum); - asm.store(dst, val); + asm.mov(dst, val); Some(KeepCompiling) } else {