This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
PowerPC optimization regression
- From: Joakim Tjernlund <joakim dot tjernlund at transmode dot se>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 8 Dec 2010 10:37:14 +0100
- Subject: PowerPC optimization regression
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,.LANCHOR0@ha
la 3,.LANCHOR0@l(3)
.L8:
lbzu 0,1(3)
cmpwi 7,0,0
bne+ 7,.L8
bdnz .L8
blr
.L10:
lis 3,.LANCHOR0@ha
la 3,.LANCHOR0@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,.LANCHOR0@ha
la 3,.LANCHOR0@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,.LC0@ha
la 3,.LC0@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)"
*/