This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
CSE regression (was Re: [patch, rfc] Make store motion use alias oracle)
- From: Dan Nicolaescu <dann at ics dot uci dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Feb 2007 14:17:49 -0800
- Subject: CSE regression (was Re: [patch, rfc] Make store motion use alias oracle)
- References: <OFBFAC585C.771589A4-ONC2257273.004DE78B-C2257273.004F8905@il.ibm.com> <200701301700.l0UH0ftE011282@oogie-boogie.ics.uci.edu>
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