[Bug optimization/12419] New: Performace regression: poor optimization of const memory
aph at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Sep 26 14:55:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12419
Summary: Performace regression: poor optimization of const memory
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aph at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
This program:
extern const int a[];
extern void f();
int foo ()
{
int n = a[0];
f();
n += a[0];
return n;
}
generates this code:
foo:
pushl %ebx
subl $8, %esp
movl a, %ebx
call f
movl a, %eax
addl $8, %esp
addl %eax, %ebx
movl %ebx, %eax
popl %ebx
ret
Note that the memory 'a' is read twice. 3.2 did this:
foo:
pushl %ebx
subl $8, %esp
movl a, %ebx
sall $1, %ebx
call f
addl $8, %esp
movl %ebx, %eax
popl %ebx
ret
More information about the Gcc-bugs
mailing list