Hi,
For this small case,
char garr[100];
void f(void)
{
unsigned short h, s;
s = 20;
for (h = 1; h < (s-1); h++)
{
garr[h] = 0;
}
}
After copyrename3, we have the following dump,
f ()
{
short unsigned int h;
int D.4066;
<bb 2>:
D.4066_14 = 1;
if (D.4066_14 <= 18)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
# h_15 = PHI <h_8(3), 1(2)>
# D.4066_16 = PHI <D.4066_4(3), D.4066_14(2)>
garr[D.4066_16] = 0;
h_8 = h_15 + 1;
D.4066_4 = (int) h_8;
if (D.4066_4 <= 18)
goto <bb 3>;
else
goto <bb 4>;
<bb 4>:
return;
}
copy renaming fails to capture the assignment statement "D.4066_4 = (int)
h_8;" to trigger renaming partition coalesce.
I find gimple_assign_single_p invoked by gimple_assign_ssa_name_copy_p
always returns false, because for this statement " gs->gsbase.subcode" is
NOP_EXPR rather than GIMPLE_SINGLE_RHS.
Should subcode be correctly initialized anywhere to fix this problem?
BTW, my expectation after copy renaming is like below,
f ()
{
int D.4679;
<bb 2>:
D.4679_7 = 1;
if (D.4679_7 != 19)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
# D.4679_15 = PHI <D.4679_4(3), D.4679_7(2)>
# D.4679_17 = PHI <D.4679_14(3), 1(2)>
garr[D.4679_15] = 0;
D.4679_14 = D.4679_17 + 1;
D.4679_4 = D.4679_14;
if (D.4679_4 != 19)
goto <bb 3>;
else
goto <bb 4>;
<bb 4>:
return;
}
and then PRE can finally remove that redundancy for symbol D.xxxx away.
Thanks,
-Jiangning