https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118298
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2025-01-07 Ever confirmed|0 |1 Component|middle-end |rtl-optimization --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- So decide_unroll_runtime_iterations figures if (desc->const_iter) { if (dump_file) fprintf (dump_file, ";; Loop iterates constant times\n"); return; } but decide_unroll_constant_iterations doesn't honor loop->unroll as we bail out too early. The following fixes this for me: iff --git a/gcc/loop-unroll.cc b/gcc/loop-unroll.cc index 2bd6e888b26..b4952055318 100644 --- a/gcc/loop-unroll.cc +++ b/gcc/loop-unroll.cc @@ -372,7 +372,8 @@ decide_unroll_constant_iterations (class loop *loop, int flags) nunroll = targetm.loop_unroll_adjust (nunroll, loop); /* Skip big loops. */ - if (nunroll <= 1) + if (nunroll <= 1 + && !(loop->unroll > 1 && loop->unroll < USHRT_MAX)) { if (dump_file) fprintf (dump_file, ";; Not considering loop, is too big\n");