YJIT: A64: Avoid intermediate register in opt_and
and friends (#10509)
Same idea as the x64 equivalent in c2622b52536c5, removing the register shuffle coming from the pop two, push one stack motion these VM instructions perform. ``` # Insn: 0004 opt_or (stack_size: 2) - orr x11, x1, x9 - mov x1, x11 + orr x1, x1, x9 ```
This commit is contained in:
parent
0a4e3f23e6
commit
2eafed0f3b
@ -431,12 +431,33 @@ impl Assembler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Insn::And { left, right, .. } |
|
Insn::And { left, right, out } |
|
||||||
Insn::Or { left, right, .. } |
|
Insn::Or { left, right, out } |
|
||||||
Insn::Xor { left, right, .. } => {
|
Insn::Xor { left, right, out } => {
|
||||||
let (opnd0, opnd1) = split_boolean_operands(asm, *left, *right);
|
let (opnd0, opnd1) = split_boolean_operands(asm, *left, *right);
|
||||||
*left = opnd0;
|
*left = opnd0;
|
||||||
*right = opnd1;
|
*right = opnd1;
|
||||||
|
|
||||||
|
// Since these instructions are lowered to an instruction that have 2 input
|
||||||
|
// registers and an output register, look to merge with an `Insn::Mov` that
|
||||||
|
// follows which puts the output in another register. For example:
|
||||||
|
// `Add a, b => out` followed by `Mov c, out` becomes `Add a, b => c`.
|
||||||
|
if let (Opnd::Reg(_), Opnd::Reg(_), Some(Insn::Mov { dest, src })) = (left, right, iterator.peek()) {
|
||||||
|
if live_ranges[index] == index + 1 {
|
||||||
|
// Check after potentially lowering a stack operand to a register operand
|
||||||
|
let lowered_dest = if let Opnd::Stack { .. } = dest {
|
||||||
|
asm.lower_stack_opnd(dest)
|
||||||
|
} else {
|
||||||
|
*dest
|
||||||
|
};
|
||||||
|
if out == src && matches!(lowered_dest, Opnd::Reg(_)) {
|
||||||
|
*out = lowered_dest;
|
||||||
|
iterator.map_insn_index(asm);
|
||||||
|
iterator.next_unmapped(); // Pop merged Insn::Mov
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
asm.push_insn(insn);
|
asm.push_insn(insn);
|
||||||
},
|
},
|
||||||
Insn::CCall { opnds, fptr, .. } => {
|
Insn::CCall { opnds, fptr, .. } => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user