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

Richard Biener <rguenth at gcc dot gnu.org> changed:

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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
This is a case where inner unswitched loops make one exit unconditional and one
never taken which means due to block loop ownership changes the outer loop
LC SSA is broken.  I don't see how this is prevented for the non-virtual
operand case or how just including the set of blocks with changed loop depth
can properly
compute LC SSA in CFG cleanup repair_loop_structures.

Specifically gimple_merge_blocks propagation of virtual PHIs "breaks" things
here but there's no other way (also inserting an assignment will still have
broken LC SSA for regular defs there, and meanwhile the a->loop_father !=
b->loop_father test works on not up-to-date loop info).

The following fixes the ICE.

diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc
index a6d0bf2c40a..b3aa6f92440 100644
--- a/gcc/tree-cfgcleanup.cc
+++ b/gcc/tree-cfgcleanup.cc
@@ -1169,25 +1169,18 @@ cleanup_tree_cfg_noloop (unsigned ssa_update_flags)
 static void
 repair_loop_structures (void)
 {
-  bitmap changed_bbs;
-  unsigned n_new_loops;
-
   calculate_dominance_info (CDI_DOMINATORS);

   timevar_push (TV_REPAIR_LOOPS);
-  changed_bbs = BITMAP_ALLOC (NULL);
-  n_new_loops = fix_loop_structure (changed_bbs);
+  fix_loop_structure (NULL);

   /* This usually does nothing.  But sometimes parts of cfg that originally
      were inside a loop get out of it due to edge removal (since they
      become unreachable by back edges from latch).  Also a former
-     irreducible loop can become reducible - in this case force a full
-     rewrite into loop-closed SSA form.  */
+     irreducible loop can become reducible - in any case it's difficult
+     to restrict the rewrite to a set of affected blocks.  */
   if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
-    rewrite_into_loop_closed_ssa (n_new_loops ? NULL : changed_bbs,
-                                 TODO_update_ssa);
-
-  BITMAP_FREE (changed_bbs);
+    rewrite_into_loop_closed_ssa (NULL, 0);

   checking_verify_loop_structure ();
   scev_reset ();

Reply via email to