This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/49127] New: -Os generates constant mov instead of instruction xor and mov when zeroing


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]