mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
LibJIT: Use test x, x
instead of cmp x, 0
in all cases
The `test` instruction will have the same result as `cmp` when comparing to zero, so let's always emit that code. This has no effect until the following commit.
This commit is contained in:
parent
bf16ddfbb0
commit
e717961000
1 changed files with 3 additions and 1 deletions
|
@ -293,7 +293,9 @@ struct Assembler {
|
|||
|
||||
void cmp(Operand lhs, Operand rhs)
|
||||
{
|
||||
if (lhs.type == Operand::Type::Reg && rhs.type == Operand::Type::Reg) {
|
||||
if (rhs.type == Operand::Type::Imm && rhs.offset_or_immediate == 0) {
|
||||
test(lhs, lhs);
|
||||
} else if (lhs.type == Operand::Type::Reg && rhs.type == Operand::Type::Reg) {
|
||||
emit8(0x48
|
||||
| ((to_underlying(rhs.reg) >= 8) ? 1 << 2 : 0)
|
||||
| ((to_underlying(lhs.reg) >= 8) ? 1 << 0 : 0));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue