[Bug tree-optimization/77975] [6/7 Regression] Missed optimization for some small constants
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Oct 14 07:55:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77975
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-10-14
CC| |law at gcc dot gnu.org,
| |marxin at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |6.1.0, 7.0
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r232361. IV canon can't identify number of iterations:
Before:
;; Function f7 (f7, funcdef_no=11, decl_uid=2279, cgraph_uid=11,
symbol_order=11)
Proved that loop 1 iterates 2 times using brute force.
Loop 1 iterates 2 times.
Loop 1 iterates at most 2 times.
Loop 1 likely iterates at most 2 times.
Added canonical iv to loop 1, 2 iterations.
f7 ()
{
unsigned int a;
unsigned int c;
struct _IO_FILE * stderr.0_1;
unsigned int ivtmp_2;
unsigned int ivtmp_3;
<bb 2>:
<bb 3>:
# c_14 = PHI <c_6(4), 0(2)>
# a_15 = PHI <a_5(4), 5(2)>
# ivtmp_3 = PHI <ivtmp_2(4), 3(2)>
a_5 = a_15 >> 1;
c_6 = c_14 + 1;
ivtmp_2 = ivtmp_3 - 1;
if (ivtmp_2 != 0)
goto <bb 4>;
else
goto <bb 5>;
<bb 4>:
goto <bb 3>;
<bb 5>:
# c_4 = PHI <c_6(3)>
stderr.0_1 = stderr;
fprintf (stderr.0_1, "cnt: %d\n", c_4);
return 0;
}
After:
;; Function f7 (f7, funcdef_no=11, decl_uid=2279, cgraph_uid=11,
symbol_order=11)
f7 ()
{
unsigned int a;
unsigned int c;
struct _IO_FILE * stderr.0_1;
<bb 2>:
<bb 3>:
# c_14 = PHI <c_6(4), 0(2)>
# a_15 = PHI <1(4), 3(2)>
a_5 = a_15 >> 1;
c_6 = c_14 + 1;
if (a_5 != 0)
goto <bb 4>;
else
goto <bb 5>;
<bb 4>:
goto <bb 3>;
<bb 5>:
# c_4 = PHI <c_6(3)>
stderr.0_1 = stderr;
fprintf (stderr.0_1, "cnt: %d\n", c_4);
return 0;
}
Diff:
# a_15 = PHI <a_5(4), 5(2)>
# a_15 = PHI <1(4), 3(2)>
Maybe ivcanon can handle such degenerated situation?
Thoughts?
More information about the Gcc-bugs
mailing list