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]

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


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