https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120560
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2025-06-05 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- We optimize away everything, leading to main: .LFB0: .cfi_startproc .cfi_endproc .LFE0: .size main, .-main .ident "GCC: (GNU) 16.0.0 20250605 (experimental) [gcc-clean2 afd06421b34]" .section .note.GNU-stack,"",@progbits aka int main () { <bb 2> [count: 0]: __builtin_unreachable (); The interesting thing is that we have Estimating # of iterations of loop 1 Estimating # of iterations of loop 1 Loop 1 iterates at most 0 times. Loop 1 likely iterates at most 0 times. ;; Guessed iterations of loop 1 is 99.999992. New upper bound 0. ;; Scaling loop 1 with scale 1.0% (guessed) to reach upper bound 0 ;; Not updating exit probability of loop 1; it has no single exit t.c:1:5: optimized: loop turned into non-loop; it never loops Latch of last iteration was marked by __builtin_unreachable (). but the input here is just int main () { <bb 2> [local count: 10631108]: <bb 3> [local count: 1073741824]: <bb 4> [local count: 1073741824]: goto <bb 3>; [100.00%] but with an upper bound for the number of iterations of zero. We have eliminated the exit in EVRP, it's input was <bb 2> : <bb 3> : # b_2 = PHI <2(2), b_8(5)> _1 = 1 - b_2; if (_1 > 6) goto <bb 4>; [INV] else goto <bb 5>; [INV] <bb 4> : // predicted unlikely by early return (on trees) predictor. return 0; <bb 5> : b_8 = b_2 + -2147483648; goto <bb 3>; [INV] which I think is OK. During EVRP we do SCEV / niter analysis and there it gets fishy, so this is likely another case of SCEV messing up overflow: Analyzing # of iterations of loop 1 exit condition [-1, + , -2147483648(OVF)](no_overflow) <= 6 bounds on difference of bases: 7 ... 7 failed Induction variable (int) -1 + -2147483648(OVF) * iteration does not wrap in statement _1 = 1 - b_2; in loop 1. Statement _1 = 1 - b_2; is executed at most 0(OVF) (bounded by 0) + 1 times in loop 1. this is the IV for _1 and that looks wrong?