https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96931

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
index b1d6e63559c..af71c269f4b 100644
--- a/gcc/tree-predcom.c
+++ b/gcc/tree-predcom.c
@@ -1960,7 +1960,8 @@ initialize_root_vars_lm (class loop *loop, dref root,
bool written,

   init = force_gimple_operand (init, &stmts, written, NULL_TREE);
   if (stmts)
-    gsi_insert_seq_on_edge_immediate (entry, stmts);
+    if (gsi_insert_seq_on_edge_immediate (entry, stmts))
+      entry = loop_preheader_edge (loop);

   if (written)
     {


guess even with simple preheaders passes need to not assume inserting
on the entry edge will not split it (the call in the preheader ends the BB
because we've had returns_twice functions).

Now the ie() call was removed and so was the abnormal edge from p3() so
likely gimple_call_ctrl_altering_p should have been cleared from it which
would be a missed optimization.  Thus an alternative fix is there.

Reply via email to