This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] cse: Lookup for both PLUS operands in an address
- From: Andreas Krebbel <krebbel1 at de dot ibm dot com>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 21 Sep 2005 10:36:57 +0200
- Subject: Re: [PATCH] cse: Lookup for both PLUS operands in an address
- References: <20050919145336.GA3422@de.ibm.com> <dgmod1$qe4$1@sea.gmane.org>
Hello,
the testcase I've used to debug this issue doesn't fail anymore
with current gcc head. The original problem occurred when I was testing
a former version of:
http://gcc.gnu.org/ml/gcc-patches/2005-09/msg01153.html
Where I was setting the symbol reference as the index part instead
of the base part. Hence the resulting address came with the PLUS
operands exchanged and that way the optimization in find_best_addr
couldn't be done.
So I must say that with that patch in place it is not a gcc 4.1
regression anymore and therefore has to wait for 4.2;
or can be dropped at all if you say you want to get rid of
find_best_addr in 4.2.
However the patch helps in cases like:
char a[10];
int
g (unsigned long u, unsigned long v)
{
int x = 0;
char *w;
w = &(a[u]);
x += *((int*)(w + v));
v += 4;
x += *((int*)(w + v));
w += 4;
x += *((int*)(w + v));
return x;
}
Without the patch cse is only able to replace one of the PLUS operands
resulting in code like:
r2 = u
r3 = v
r4 = r3
r4 += 4
r2 += &a
r1 = [r3 + r2]
r1 += [r4 + r2]
r1 += [r4 + r2 + 4]
And with the patch applied we get:
r2 = u
r3 = v
r2 += &a
r1 = [r3 + r2]
r1 += [r3 + r2 + 4]
r1 += [r3 + r2 + 8]
Bye,
-Andreas-