https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97623
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- So this is the change improving the hoist insert situation but it is not a solution for the back-to-back of PRE vs. hoist insertion. Will have to think about this some more and then eventually simply add some iteration limit - we can stop after any arbitrary number of iterations after all, the cost is just less optimization. As a workaround for older code bases I suggest to use -fno-code-hoisting for now. If you are set up to try current trunk GCC then I'd be curious to know the effect of the patch on the "real" case.