This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Poor strength reduction with autoincrements
- To: egcs at egcs dot cygnus dot com
- Subject: Poor strength reduction with autoincrements
- From: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>
- Date: Sat, 17 Apr 1999 14:39:49 +1200 (NZST)
The one area that I'm finding that egcs is consistently generating
poor code (compared with gcc-2.7.2) is strength reduction for machines
with autoincrement addressing. One would think that strength
reduction should improve the performance of autoincrement addressing
but I'm finding that I often get better code for the c4x by disabling
it.
Some of the problems stem from a poor choice of GIVs to combine.
Richard Henderson posted a patch a few months ago that fixed many of
these problems but this patch has bever been committed.
Another problem occurs when a new GIV is unecessarily created and
where the GIV it was derived from is used after the loop. This leads
to a redundant increment within the loop and increased register
pressure. The following contrived function demonstrates this:
int foo(unsigned short *dest, const unsigned char *src, int bytes)
{
int i;
for (i = 0; i < bytes; i++)
{
unsigned int tmp;
tmp = *src++ & 0xff;
tmp |= *src++;
*dest++ = tmp;
}
return *src;
}
The generated code for the c4x is:
<snip...>
lda ar1,ar0 <= new GIV initialised
L6:
ldiu *ar0,r0
and 255,r0
or3 *+ar0(1),r0,r0
addi3 2,ar0,ar0 <= new GIV incremented
addi3 2,ar1,ar1 <= old GIV incremented
addi3 -1,r1,r1
bned L6
sti r0,*ar2++
nop
nop
L4:
ldiu *ar1,r0
rets
Note that the new and old GIVs are equivalent and thus the new one is
redundant.
Does anyone have any suggestions where I should look in loop.c to fix
this problem?
Michael.