optimization/9566: Inline function produces much worse code than manual inlining.
Andrew Pinski
pinskia@physics.uc.edu
Mon Apr 14 23:36:00 GMT 2003
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-
trail&database=gcc&pr=9566
The problem is because inlining causes a temporary variable which
causes this and causes it to spill to the stack.
struct A {
char const* src;
char* dest;
void copy() { *++dest = *++src; }
};
void g1() {
A a;
for(int i = 0; i < 10; ++i)
a.copy();
}
void g2() {
A a;
for(int i = 0; i < 10; ++i)
*++a.dest = *++a.src;
}
void g3() {
A a;
for(int i = 0; i < 10; ++i)
{
struct A b = a;
{
*++b.dest = *++b.src;
}
a = b;
}
}
Note here g3 and g1 produce the same asm on PPC.
Thanks,
Andrew Pinski
More information about the Gcc-bugs
mailing list