This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/41488] New: IVOpts cannot coalesce multiple induction variables
- From: "rahul at icerasemi dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Sep 2009 12:44:42 -0000
- Subject: [Bug tree-optimization/41488] New: IVOpts cannot coalesce multiple induction variables
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Using GCC 4.4.1 release version and compiling the following test with
gcc -O2 -fdump-tree-all
struct struct_t {
int* data;
};
void testAutoIncStruct (struct struct_t* sp, int start, int end) {
int i;
for (i = 0; i+start < end; i++)
{
sp->data[i+start] = 0;
}
}
IVOpts dump shows induction variables (start and ivtmp.32) cannot be coalesced
testAutoIncStruct (struct struct_t * sp, int start, int end) {
unsigned int D.1283;
unsigned int D.1284;
int D.1282;
unsigned int ivtmp.32;
int * pretmp.17;
int i;
int * D.1245;
unsigned int D.1244;
unsigned int D.1243;
<bb 2>:
if (start_3(D) < end_5(D))
goto <bb 3>;
else
goto <bb 6>;
<bb 3>:
pretmp.17_22 = sp_6(D)->data;
D.1282_23 = start_3(D) + 1;
ivtmp.32_25 = (unsigned int) D.1282_23;
D.1283_27 = (unsigned int) end_5(D);
D.1284_28 = D.1283_27 + 1;
<bb 4>:
# start_20 = PHI <start_4(5), start_3(D)(3)>
# ivtmp.32_7 = PHI <ivtmp.32_24(5), ivtmp.32_25(3)>
D.1243_9 = (unsigned int) start_20;
D.1244_10 = D.1243_9 * 4;
D.1245_11 = pretmp.17_22 + D.1244_10;
*D.1245_11 = 0;
start_26 = (int) ivtmp.32_7;
start_4 = start_26;
ivtmp.32_24 = ivtmp.32_7 + 1;
if (ivtmp.32_24 != D.1284_28)
goto <bb 5>;
else
goto <bb 6>;
<bb 5>:
goto <bb 4>;
<bb 6>:
return;
}
The problem arises from expression "i + start" being identified as a common
expression between the header and the latch. This seems to creates an extra
induction variable and a PHI in the latch. If we disable tree FRE and tree copy
propagation with
gcc -O2 -fno-tree-fre -fno-tree-copy-prop
We get
<bb 3>:
pretmp.17_23 = sp_6(D)->data;
D.1287_27 = (unsigned int) end_5(D);
D.1288_28 = (unsigned int) start_3(D);
D.1289_29 = D.1287_27 - D.1288_28;
D.1290_30 = (int) D.1289_29;
<bb 4>:
# i_20 = PHI <i_12(5), 0(3)>
D.1241_7 = pretmp.17_23;
D.1284_26 = (unsigned int) start_3(D);
D.1285_25 = (unsigned int) i_20;
D.1286_24 = D.1284_26 + D.1285_25;
MEM[base: pretmp.17_23, index: D.1286_24, step: 4] = 0;
i_12 = i_20 + 1;
if (i_12 != D.1290_30)
goto <bb 5>;
else
goto <bb 6>;
The induction variable and the memory reference is now correctly identified.
--
Summary: IVOpts cannot coalesce multiple induction variables
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rahul at icerasemi dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41488