https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111563
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- _5 = var_0_16(D) + var_6_18(D); invariant up to level 1, cost 1. Basically because the cost is not high enough ... If you use --param=lim-expensive=1. then it will pull it out of the loop. So the cost model is doing the correct thing here ...