If CHANGED_BBS is not NULL, basic blocks whose loop depth has changed are
marked in it.
- Returns the number of new discovered loops. */
+ Returns the number of new discovered plus the number of removed loops. */
unsigned
fix_loop_structure (bitmap changed_bbs)
}
/* Finally free deleted loops. */
- bool any_deleted = false;
+ unsigned n_deleted = 0;
class loop *loop;
FOR_EACH_VEC_ELT (*get_loops (cfun), i, loop)
if (loop && loop->header == NULL)
}
(*get_loops (cfun))[i] = NULL;
flow_loop_free (loop);
- any_deleted = true;
+ n_deleted++;
}
/* If we deleted loops then the cached scalar evolutions refering to
those loops become invalid. */
- if (any_deleted && scev_initialized_p ())
+ if (n_deleted > 0 && scev_initialized_p ())
scev_reset_htab ();
loops_state_clear (LOOPS_NEED_FIXUP);
timevar_pop (TV_LOOP_INIT);
- return number_of_loops (cfun) - old_nloops;
+ return number_of_loops (cfun) - old_nloops + n_deleted;
}
\f
/* The RTL loop superpass. The actual passes are subpasses. See passes.cc for
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-funswitch-loops" } */
+
+short var_32;
+int test_var_0;
+unsigned char test_var_6;
+char test_var_13;
+void test(int var_2)
+{
+ for (;;)
+ for (short i_7; i_7 < test_var_13; i_7 += 1)
+ for (; test_var_0;) {
+ for (; var_2;)
+ var_32 = 0;
+ for (char i_19; i_19 < test_var_6 + 135; i_19 += 200)
+ ;
+ }
+}
repair_loop_structures (void)
{
bitmap changed_bbs;
- unsigned n_new_loops;
+ unsigned n_new_or_deleted_loops;
calculate_dominance_info (CDI_DOMINATORS);
timevar_push (TV_REPAIR_LOOPS);
changed_bbs = BITMAP_ALLOC (NULL);
- n_new_loops = fix_loop_structure (changed_bbs);
+ n_new_or_deleted_loops = fix_loop_structure (changed_bbs);
/* 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
irreducible loop can become reducible - in this case force a full
rewrite into loop-closed SSA form. */
if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
- rewrite_into_loop_closed_ssa (n_new_loops ? NULL : changed_bbs,
+ rewrite_into_loop_closed_ssa (n_new_or_deleted_loops ? NULL : changed_bbs,
TODO_update_ssa);
BITMAP_FREE (changed_bbs);