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

           Summary: PowerPC optimization regression
           Product: gcc
           Version: 4.4.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: joakim.tjernl...@transmode.se


I have noticed gcc 4.4.5 often produces less optimzed code
than the old 3.4.6. Below is the latest example. I am
starting to wonder if I need rebuild gcc 4.4.5 and/or
add new options to gcc when I compile. Any insight?

 Jocke

const char *test(int i)
{
    const char *p = "abc\0def\0gef";
    for(; i; --i)
        while(*++p);
    return p;
}

/* gcc 4.4.5 -O2 -S
       .section        ".text"
        .align 2
        .globl test
        .type   test, @function
test:
        mr. 0,3
        mtctr 0
        beq- 0,.L10
        lis 3,.lanch...@ha
        la 3,.lanch...@l(3)
.L8:
        lbzu 0,1(3)
        cmpwi 7,0,0
        bne+ 7,.L8
        bdnz .L8
        blr
.L10:
        lis 3,.lanch...@ha
        la 3,.lanch...@l(3)
        blr
        .size   test, .-test
        .section        .rodata
        .align 2
        .set    .LANCHOR0,. + 0
.LC0:
        .string "abc"
        .string "def"
        .string "gef"
        .ident  "GCC: (Gentoo 4.4.5 p1.0, pie-0.4.5) 4.4.5"
 */
/* gcc 4.4.5 -Os -S
.globl test
        .type   test, @function
test:
        mr 9,3
        lis 3,.lanch...@ha
        la 3,.lanch...@l(3)
        b .L2
.L5:
        lbzu 0,1(3)
        cmpwi 7,0,0
        bne+ 7,.L5
        addi 9,9,-1
.L2:
        cmpwi 7,9,0
        bne+ 7,.L5
        blr
        .size   test, .-test
        .section        .rodata
        .set    .LANCHOR0,. + 0
.LC0:
        .string "abc"
        .string "def"
        .string "gef"
        .ident  "GCC: (Gentoo 4.4.5 p1.0, pie-0.4.5) 4.4.5"
 */

/* gcc 3.4.6 -Os -S and gcc -O2 -S
section        .rodata
        .align 2
.LC0:
        .string "abc"
        .string "def"
        .string "gef"
        .section        ".text"
        .align 2
        .globl test
        .type   test, @function
test:
        mr. 0,3
        lis 9,....@ha
        la 3,....@l(9)
        mtctr 0
        beqlr- 0
.L13:
        lbzu 0,1(3)
        cmpwi 7,0,0
        bne- 7,.L13
        bdnz .L13
        blr
        .size   test, .-test
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.9)"
*/

Reply via email to