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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yep this fixes the ICE:
```
diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc
index 9f82abc4b81..f5d63c74060 100644
--- a/gcc/tree-scalar-evolution.cc
+++ b/gcc/tree-scalar-evolution.cc
@@ -3947,11 +3947,13 @@ final_value_replacement_loop (class loop *loop)
         GENERIC interface).  */
       def = unshare_expr (def);
       auto loc = gimple_phi_arg_location (phi, exit->dest_idx);
-      remove_phi_node (&psi, false);

       /* Create the replacement statements.  */
       gimple_seq stmts;
       def = force_gimple_operand (def, &stmts, false, NULL_TREE);
+
+      /* Remove the phi only after the gimplification. */
+      remove_phi_node (&psi, false);
       gassign *ass = gimple_build_assign (rslt, def);
       gimple_set_location (ass, loc);
       gimple_seq_add_stmt (&stmts, ass);

```

Reply via email to