Re: [PATCH 1/1] x86: Change mov $0, %reg with xor %reg, %reg

From: Kanna Scarlet
Date: Mon Aug 08 2022 - 12:39:03 EST


On 8/5/22 4:26 PM, David Laight wrote:
Use "xor %rax,%rax" instead of "xor %eax,%eax" to save
the 'reg' prefix.

hello David Laight

"xor %rax,%rax" is bigger because of rex prefix, "xor %eax,%eax" is smaller
because it doesn't need rex prefix.

asm:
0: 48 31 c0 xor %rax,%rax
3: 31 c0 xor %eax,%eax

so i think to save from rex prefix, use xor %eax,%eax instead of xor %rax,%rax.

Best regards,
--
Kanna Scarlet