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/16427] New: dead 0 memset not optimized away


gcc version 3.5.0 20040704 (experimental)

void f(void)
{
        unsigned long x[16];
        memset(x, 0, sizeof(x));
}

generates 

f:
.LFB2:
        subq    $136, %rsp
.LCFI0:
        movl    $128, %edx
        xorl    %esi, %esi
        movq    %rsp, %rdi
        call    memset
        addq    $136, %rsp
        ret

but when the 0 is changed to 0xff or any other value != 0 you get

f:
.LFB2:
        subq    $16, %rsp
.LCFI0:
        addq    $16, %rsp
        ret

(which btw is also weird because it leaks 16 bytes, but that's a differen issue)

I would expect the 0 memset to be optimized away too.

Looking at the code builtin_memset calls clear_storage() for the 0 case
and store_by_pieces directly for any other values.
Clearly something clear_storage() does is giving the optimizer the fits.

-- 
           Summary: dead 0 memset not optimized away
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ak at muc dot de
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: x86_64-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16427


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