https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114145
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2024-02-28
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Store motion turns this into
<bb 2> [local count: 10737416]:
b_lsm.3_3 = _15(D);
c_7 = a;
<bb 3> [local count: 1063004408]:
# c_12 = PHI <c_7(5), c_4(D)(2)>
# i_13 = PHI <i_8(5), 0(2)>
b_lsm.3_2 = c_12;
i_8 = i_13 + 1;
if (i_8 != 700)
goto <bb 5>; [98.99%]
else
goto <bb 4>; [1.01%]
<bb 5> [local count: 1052266995]:
goto <bb 3>; [100.00%]
<bb 4> [local count: 10737416]:
# b_lsm.3_11 = PHI <b_lsm.3_2(3)>
b = b_lsm.3_11;
return;
where ultimatively final value replacement fails because SCEV fails here:
(analyze_scalar_evolution
(loop_nb = 1)
(scalar = c_7)
(get_scalar_evolution
(scalar = c_7)
(scalar_evolution = ))
)
(instantiate_scev
(instantiate_below = 2 -> 3)
(evolution_loop = 1)
(chrec = c_7)
(res = c_7))
(evolution_function = scev_not_known))
indeed there's no way to express the evolution of this induction variable
which has just two values. Might be a simple thing to special case
in final value replacement though. There we see just
<bb 3> [local count: 1063004408]:
# c_12 = PHI <c_7(5), c_4(D)(2)>
...
<bb 4> [local count: 10737416]:
# c_9 = PHI <c_12(3)>
so the final value is niter == 0 ? c_4(D) : c_7.