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

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

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think it's fixed by

diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc
index a405119b58a..ec1468ab0af 100644
--- a/gcc/tree-ssa-loop-unswitch.cc
+++ b/gcc/tree-ssa-loop-unswitch.cc
@@ -745,6 +745,9 @@ empty_bb_without_guard_p (class loop *loop, basic_block bb)
        !gsi_end_p (gsi); gsi_next (&gsi))
     {
       gimple *stmt = gsi_stmt (gsi);
+      if (is_gimple_debug (stmt))
+       continue;
+
       if (gimple_has_side_effects (stmt))
        return false;

@@ -772,7 +775,8 @@ used_outside_loop_p (class loop *loop, tree name)
   FOR_EACH_IMM_USE_FAST (use, it, name)
     {
       gimple *stmt = USE_STMT (use);
-      if (!flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
+      if (!is_gimple_debug (stmt)
+         && !flow_bb_inside_loop_p (loop, gimple_bb (stmt)))
        return true;
     }

but that exposes

> ./cc1 -quiet t.c -O2 -funswitch-loops -fdump-tree-unswitch-details -g
t.c: In function 'main':
t.c:27:5: error: definition in block 12 does not dominate use in block 15
   27 | int main() { e(); }
      |     ^~~~
for SSA_NAME: _13 in statement:
# DEBUG f => _13
during GIMPLE pass: unswitch
dump file: t.c.152t.unswitch
t.c:27:5: internal compiler error: verify_ssa failed
0x1783a48 verify_ssa(bool, bool)
        /home/rguenther/src/gcc3/gcc/tree-ssa.cc:1211

because we fail to reset debug stmts for such uses.  So there's some work to
be done.  The transform in question is that we're hoisting a guard.

Reply via email to