https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90316
--- Comment #27 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 46337 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46337&action=edit untested patch So this is another patch adjusting PRE insertion to only iterate when necessary (well, I think it should be never necessary to iterate...). That said, it strips iteration down to a minimum (still supporting the notion that iteration is necessary at all). I wonder if iteration in the end is really only because of the sorting order issue, thus if the patch doesn't help, can you try changing the hunk @@ -3326,6 +3331,10 @@ do_pre_regular_insertion (basic_block bl } } } + /* ??? Imperfect sorting of expressions means we have to iterate here. + For example gcc.dg/tree-ssa/pr23455.c shows a dependent memory + load cannot be inserted as part of a computation. */ + } while (old_trans_fails != trans_fails); exprs.release (); return new_stuff; to never loop and try again? (this particular looping is a hack implementation-wise and probably can be improved or even avoided)