https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117875
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at gcc dot gnu.org, | |amacleod at redhat dot com --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Note the branch and exit condition are nicely present in the IL but indeed there doesn't seem to be any infrastructure for special-casing known constant amount of iteration and there's no cleanup done before more loop opts mess things up. I'm also not sure we'd handle this case with VRPs relation support, niter analysis tries to simplify computed nonzero conditions, but just with its weak simplify_using_initial_conditions which isn't even able to compute M_9(D) < k_24 (aka the nonzero condition) as true. We don't simplify the computed niter expression itself. The niter expression is (unsigned int) M_9(D) - (unsigned int) k_24. I'm not sure what ranger has at its disposal for us here when trying to simplify GENERIC expressions, we could possibly try to compute it's range and if that's singleton use that? <bb 13> [local count: 105119324]: if (M_9(D) > 1) goto <bb 14>; [64.00%] else goto <bb 15>; [36.00%] <bb 14> <bb 3> [local count: 611603345]: // first loop # k_15 = PHI <k_12(8), 1(14)> ... k_12 = k_15 + 1; if (k_12 < M_9(D)) goto <bb 8>; [89.00%] // latch else goto <bb 16>; [11.00%] <bb 16> [local count: 67276368]: # k_29 = PHI <k_12(3)> if (M_9(D) >= k_29) goto <bb 15>; [99.95%] else goto <bb 6>; [0.05%] <bb 15> [local count: 105119324]: # k_24 = PHI <1(13), k_29(16)> // 1 is from loop-around branch <bb 9> [local count: 343854870]: // second loop # k_17 = PHI <k_24(15), k_23(12)> ... k_23 = k_17 + 1; if (M_9(D) >= k_23)