mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibJIT: Encode mov(reg, 0) as xor(reg, reg)
This uses less space for the same result. :^)
This commit is contained in:
parent
5b87d26027
commit
d09bc54586
1 changed files with 7 additions and 0 deletions
|
@ -122,6 +122,13 @@ struct Assembler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst.type == Operand::Type::Reg && src.type == Operand::Type::Imm64) {
|
if (dst.type == Operand::Type::Reg && src.type == Operand::Type::Imm64) {
|
||||||
|
if (src.offset_or_immediate == 0) {
|
||||||
|
// xor dst, dst
|
||||||
|
emit8(0x48 | ((to_underlying(dst.reg) >= 8) ? 1 << 0 : 0));
|
||||||
|
emit8(0x31);
|
||||||
|
emit8(0xc0 | (encode_reg(dst.reg) << 3) | encode_reg(dst.reg));
|
||||||
|
return;
|
||||||
|
}
|
||||||
emit8(0x48 | ((to_underlying(dst.reg) >= 8) ? 1 << 0 : 0));
|
emit8(0x48 | ((to_underlying(dst.reg) >= 8) ? 1 << 0 : 0));
|
||||||
emit8(0xb8 | encode_reg(dst.reg));
|
emit8(0xb8 | encode_reg(dst.reg));
|
||||||
emit64(src.offset_or_immediate);
|
emit64(src.offset_or_immediate);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue