This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/36905] New: IV-opts needs a little help with a[i+1]
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2008 02:09:34 -0000
- Subject: [Bug tree-optimization/36905] New: IV-opts needs a little help with a[i+1]
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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