https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97891
--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
(In reply to Hongtao.liu from comment #3)
> This problem is very similar to the one pass_rpad deals with.
We already have mov<mode>_xor for mov $0 to reg, so we only need to handle mov
$0 to mem.
and size for:
xorl --- 2 byte
$0 in movb ----- 1 byte
$0 in movw ----- 2 byte
$0 in mov{l,q} ----- 4 byte
0: 31 d2 xor %edx,%edx
2: 48 c7 07 00 00 00 00 movq $0x0,(%rdi)
9: 48 89 37 mov %rsi,(%rdi)
c: 88 17 mov %dl,(%rdi)
e: c6 07 00 movb $0x0,(%rdi)
11: 66 89 17 mov %dx,(%rdi)
14: 66 c7 07 00 00 movw $0x0,(%rdi)
19: 89 3f mov %edi,(%rdi)
1b: c7 07 00 00 00 00 movl $0x0,(%rdi)
As long as immediate $0 occupied more than 2 bytes, it would be codesize
beneficial to replace mov $0, mem with xor reg0, reg0 + mov reg0, mem.