This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/9566: Inline function produces much worse code than manual inlining.
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: gcc-gnats at gcc dot gnu dot org, osv at javad dot ru, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Mon, 14 Apr 2003 19:35:58 -0400
- Subject: Re: optimization/9566: Inline function produces much worse code than manual inlining.
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