This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/53676] [4.7/4.8 regression] empty loop is not always removed now
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 19 Jun 2012 13:18:19 +0000
- Subject: [Bug middle-end/53676] [4.7/4.8 regression] empty loop is not always removed now
- Auto-submitted: auto-generated
- References: <bug-53676-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53676
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-19 13:18:19 UTC ---
First of all confirmed. We rely on SCCP to compute the overall loop effect
which does not happen anymore. The loops are different - 4.6 has
<bb 14>:
# result_81 = PHI <result_44(13), 0(21)>
# n_78 = PHI <n_46(13), 0(21)>
result.7_42 = (unsigned char) result_81;
D.7248_43 = result.7_42 + 2;
result_44 = (signed char) D.7248_43;
n_46 = n_78 + 1;
if (n_46 != 8000)
goto <bb 13>;
else
goto <bb 15>;
but with 4.7 we see
<bb 16>:
# result_76 = PHI <result_50(15), 0(22)>
# n_77 = PHI <n_52(15), 0(22)>
D.7583_48 = (int) result_76;
D.7582_49 = D.7583_48 + 2;
result_50 = (signed char) D.7582_49;
n_52 = n_77 + 1;
if (n_52 != 8000)
goto <bb 15>;
else
goto <bb 17>;
thus 4.6 performed the premature shortening optimization that 4.7 no longer
performs.
Testcase that nobody handles because it has the operation explicitely in int:
int main()
{
int i;
signed char result = 0;
for (i = 0; i != 8000; ++i)
{
int tem = result;
tem = tem + 2;
result = tem;
}
if (__builtin_abs ((int)(signed char)((unsigned char ) result + 128)) != 0)
__builtin_abort ();
return 0;
}
Proper action could be to implement that shortening inside forwprop or
to teach the trick to SCEV analysis.