YJIT: x64: Remove register shuffle with opt_and
and friends (#10498)
This is best understood by looking at the change to the output: ```diff # Insn: 0002 opt_and (stack_size: 2) - mov rax, rsi - and rax, rdi - mov rsi, rax + and rsi, rdi ``` It's a bit awkward to match against due to how stack operands are lowered, but hey, it's nice to save the 2 unnecessary MOVs.
This commit is contained in:
parent
db0cf1aef9
commit
c2622b5253
@ -181,6 +181,23 @@ impl Assembler
|
|||||||
iterator.map_insn_index(&mut asm);
|
iterator.map_insn_index(&mut asm);
|
||||||
iterator.next_unmapped(); // Pop merged Insn::Mov
|
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]) {
|
match (unmapped_opnds[0], unmapped_opnds[1]) {
|
||||||
(Opnd::Mem(_), Opnd::Mem(_)) => {
|
(Opnd::Mem(_), Opnd::Mem(_)) => {
|
||||||
|
@ -3827,7 +3827,7 @@ fn gen_opt_and(
|
|||||||
|
|
||||||
// Push the output on the stack
|
// Push the output on the stack
|
||||||
let dst = asm.stack_push(Type::Fixnum);
|
let dst = asm.stack_push(Type::Fixnum);
|
||||||
asm.store(dst, val);
|
asm.mov(dst, val);
|
||||||
|
|
||||||
Some(KeepCompiling)
|
Some(KeepCompiling)
|
||||||
} else {
|
} else {
|
||||||
@ -3867,7 +3867,7 @@ fn gen_opt_or(
|
|||||||
|
|
||||||
// Push the output on the stack
|
// Push the output on the stack
|
||||||
let dst = asm.stack_push(Type::Fixnum);
|
let dst = asm.stack_push(Type::Fixnum);
|
||||||
asm.store(dst, val);
|
asm.mov(dst, val);
|
||||||
|
|
||||||
Some(KeepCompiling)
|
Some(KeepCompiling)
|
||||||
} else {
|
} else {
|
||||||
@ -3909,7 +3909,7 @@ fn gen_opt_minus(
|
|||||||
|
|
||||||
// Push the output on the stack
|
// Push the output on the stack
|
||||||
let dst = asm.stack_push(Type::Fixnum);
|
let dst = asm.stack_push(Type::Fixnum);
|
||||||
asm.store(dst, val);
|
asm.mov(dst, val);
|
||||||
|
|
||||||
Some(KeepCompiling)
|
Some(KeepCompiling)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user