This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36770] New: PowerPC generated PTR code ineffiency
- From: "gunnar at greyhound-data dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jul 2008 14:56:27 -0000
- Subject: [Bug c/36770] New: PowerPC generated PTR code ineffiency
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC fails to generate efficient code for basic pointer operations.
Please have a look at this example:
***
test.c:
register int * src asm("r15");
int test( ){
src[1]=src[0];
src++;
}
main(){
}
***
compile the above with gcc -S -O3 test.c
shows us the following ASM output:
test:
mr 9,15
addi 15,15,4
lwz 0,0(9)
stw 0,4(9)
blr
compile with gcc -S -Os test.c
Gives this output
test:
mr 9,15
addi 15,15,4
lwz 0,0(9)
stw 0,4(9)
blr
As you can see both -O3 and -Os produce the same output.
The generated output is far from optimal.
GCC generates for the simple pointer operation this code:
mr 9,15
addi 15,15,4
lwz 0,0(9)
stw 0,4(9)
But GCC should rather generate this:
lwz 0,0(15)
stwu 0,4(15)
Two of the four instructions are unneeded.
We've here code with literally thousands of unneeded instructions generated
like this.
I very much hope that this information is helpful to you and that you can fix
this.
Many thanks in advance
Gunnar von Boehn
--
Summary: PowerPC generated PTR code ineffiency
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gunnar at greyhound-data dot com
GCC build triplet: powerpc64-unknown-linux-gnu
GCC host triplet: powerpc64-unknown-linux-gnu
GCC target triplet: powerpc64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36770