[Bug middle-end/41743] New: Missing loop optimisation

segher at kernel dot crashing dot org gcc-bugzilla@gcc.gnu.org
Sun Oct 18 14:00:00 GMT 2009


Take the following example code:

void *memset(void *b, int c, unsigned long len)
{
        unsigned long i;

        for (i = 0; i < len; i++)
                ((unsigned char *)b)[i] = c;

        return b;
}

-O2 generates:

memset:
        cmpwi 0,5,0
        beqlr 0
        mtctr 5
        rlwinm 4,4,0,0xff
        li 9,0
        .p2align 4,,15
.L3:
        stbx 4,3,9
        addi 9,9,1
        bdnz .L3
        blr

The use of GPR9 is unnecessary, the loop could increment
GPR3 instead.


-- 
           Summary: Missing loop optimisation
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: segher at kernel dot crashing dot org
GCC target triplet: powerpc-linux


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



More information about the Gcc-bugs mailing list