[Bug rtl-optimization/49127] New: -Os generates constant mov instead of instruction xor and mov when zeroing
msharov at users dot sourceforge.net
gcc-bugzilla@gcc.gnu.org
Mon May 23 15:44:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49127
Summary: -Os generates constant mov instead of instruction xor
and mov when zeroing
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: msharov@users.sourceforge.net
void zero (void* p) { *reinterpret_cast<ulong*>(p) = 0; }
Generates:
48 c7 07 00 00 00 00 movq $0x0,(%rdi)
This is shorter by 2 bytes:
31 c0 xor %eax,%eax
48 89 07 mov %rax,(%rdi)
And can be reused in further assignments of zero for more savings:
31 c0 xor %eax,%eax
48 89 07 mov %rax,(%rdi)
48 89 47 04 mov %rax,0x4(%rdi)
More information about the Gcc-bugs
mailing list