This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/49127] New: -Os generates constant mov instead of instruction xor and mov when zeroing
- From: "msharov at users dot sourceforge.net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 23 May 2011 15:33:44 +0000
- Subject: [Bug rtl-optimization/49127] New: -Os generates constant mov instead of instruction xor and mov when zeroing
- Auto-submitted: auto-generated
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)