This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/39102] gcc generating multiple stack stores in optimised code
- From: "jens.maurer at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 23 Nov 2012 14:07:34 +0000
- Subject: [Bug target/39102] gcc generating multiple stack stores in optimised code
- Auto-submitted: auto-generated
- References: <bug-39102-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39102
--- Comment #2 from Jens Maurer <jens.maurer at gmx dot net> 2012-11-23 14:07:34 UTC ---
Here is another test case:
struct S {
unsigned char * p;
unsigned char * limit;
};
S g(S s);
inline __attribute__((always_inline)) S f(S s, unsigned int n);
S f(S s, unsigned int n)
{
if (__builtin_expect(s.p + n < s.limit, 1)) {
s.p += n;
return s;
}
return g(s);
}
extern S sext;
int main()
{
S s = sext;
s = f(s, 4);
s = f(s, 8);
s = f(s, 2);
return (int)(unsigned long)s.p;
}
leading to
movq %rax, (%rsp)
movq %rdx, 8(%rsp)
in the code paths calling g(s), although "s" is kept in registers throughout.