------- Comment #17 from rguenth at gcc dot gnu dot org 2009-02-08 14:45
-------
The situation is still worse than originally reported. Even without PRE we
have
Analyzing # of iterations of loop 2
exit condition [1, + , 1] <= i1_6(D)
bounds on difference of bases: -1 ... 2147483646
result:
under assumptions i1_6(D) != 2147483647
# of iterations (unsigned int) i1_6(D), bounded by 2147483647
(set_nb_iterations_in_loop = scev_not_known))
for the inner loop which is just
<bb 4>:
<bb 5>:
# i_13 = PHI <i_8(4), 0(9)>
D.1244_7 = j_10 + 1;
bar (D.1244_7);
i_8 = i_13 + 1;
if (i1_6(D) >= i_8)
goto <bb 4>;
else
goto <bb 6>;
...
<bb 8>:
# j_10 = PHI <j_9(7), 0(3)>
if (i1_6(D) >= 0)
goto <bb 9>;
else
goto <bb 6>;
<bb 9>:
goto <bb 5>;
which means we cannot prove that with i_8 = {1, +, 1}_2 the loop
runs at least once if only i1_6 >= 0 is known (remember its the number
of latch executions that are counted).
Smaller testcase:
void bar();
void foo(int i1)
{
int i;
for (i=0; i<=i1; ++i)
bar();
}
It "works" once you change the loop exit condition to i < i1. Same effects
with unsigned variables (adjust the lower bound to sth like 2 to avoid ill
effects).
I changed the Summary to what is more appropriate.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rakdver at gcc dot gnu dot
| |org
Status|WAITING |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-02-08 14:45:08
date| |
Summary|loop number of iterations |loop number of iterations
|analysis confused by what |analysis not working
|PRE did (PRE is doing its |
|job) |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26939