[Bug tree-optimization/36905] New: IV-opts needs a little help with a[i+1]
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Jul 23 02:10:00 GMT 2008
Take:
void fred(unsigned short in, unsigned short *out1)
{
__SIZE_TYPE__ i;
for (i=0;i<100;i++)
out1[i+1] = in;
}
For PPC we currently generate:
.L2:
addi 9,9,1
slwi 0,9,1
sthx 3,4,0
bdnz .L2
But if change the code just so slightly to:
void fred(unsigned short in, unsigned short *out1)
{
__SIZE_TYPE__ i;
out1 ++;
for (i=0;i<100;i++)
out1[i] = in;
}
--- CUT ---
we get great code:
.L2:
sthu 3,2(4)
bdnz .L2
Even without update we still get:
.L2:
sth 3,2(4)
addi 4,4,2
bdnz .L2
Even if we use the variable out1 afterwards (by a return), we still get the
better code in the second case.
--
Summary: IV-opts needs a little help with a[i+1]
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
GCC target triplet: powerpc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36905
More information about the Gcc-bugs
mailing list