This is the mail archive of the gcc-patches@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]

CSE regression (was Re: [patch, rfc] Make store motion use alias oracle)


Dan Nicolaescu <dann@ics.uci.edu> writes:

  > struct s {  int a;  int b;};
  > void foo (struct s *ps,  int *p, int *__restrict__ rp, int
  > *__restrict__ rq)
  > {
  >   ps->a = 0;
  >   ps->b = 1;
  >   if (ps->a != 0)    abort ();
  >   p[0] = 0;
  >   p[1] = 1;
  >   if (p[0] != 0)     abort ();
  >   rp[0] = 0;
  >   rq[0] = 1;
  >   if (rp[0] != 0)     abort();
  > }
  > 
  > [Ooop it looks like there's a regression on the code above!] 
  > The 4.1 (and earlier)  -O2 assembly looks like this: 
  > 
  > bar:
  >         movl    4(%esp), %eax
  >         movl    8(%esp), %edx
  >         movl    $0, (%eax)
  >         movl    $1, 4(%eax)
  >         movl    12(%esp), %eax
  >         movl    $0, (%edx)
  >         movl    $1, 4(%edx)
  >         movl    $0, (%eax)
  >         movl    16(%esp), %eax
  >         movl    $1, (%eax)
  >         ret
  > 
  > whereas now SVN HEAD generates:
  > 
  >         subl    $12, %esp
  >         movl    16(%esp), %eax
  >         movl    20(%esp), %edx
  >         movl    24(%esp), %ecx
  >         movl    $0, (%eax)
  >         movl    $1, 4(%eax)
  >         movl    (%eax), %eax
  >         testl   %eax, %eax
  >         jne     .L20
  >         movl    $0, (%edx)
  >         movl    (%edx), %eax
  >         movl    $1, 4(%edx)
  >         testl   %eax, %eax
  >         jne     .L20
  >         movl    $0, (%ecx)
  >         movl    (%ecx), %ecx
  >         movl    28(%esp), %eax
  >         testl   %ecx, %ecx
  >         movl    $1, (%eax)
  >         jne     .L20
  >         addl    $12, %esp
  >         ret
  > .L20:
  >         call    abort
  > 
  > I'll file a bug report.

The bug report for this is PR30643, the patch that caused the
regression has been identified in the PR. Given that nothing else can
currently perform the above optimization it probably has some
performance impact... 

The above codes has been optimized since at least gcc-3.0


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