https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85143
--- Comment #2 from robertw89 at googlemail dot com --- This change would be trivial. To defend my case and rant a bit ;) ... Indeed, but programmers can manually unroll a loop too ;) . What if the code is autogenerated? What if the constant comes from a devirtualized call, etc. It could do this optimization.