This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/39102] gcc generating multiple stack stores in optimised code


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]