--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim2-details" } */
+
+volatile int flag, bar;
+double foo (double *valp)
+{
+ double sum = 0;
+ for (int i = 0; i < 256; ++i)
+ {
+ if (flag)
+ for (int j = 0; j < 256; ++j)
+ bar = flag;
+ if (flag)
+ sum += 1.;
+ sum += *valp; // we should move the load of *valp out of the loop
+ }
+ return sum;
+}
+
+/* { dg-final { scan-tree-dump-times "Moving statement" 1 "lim2" } } */
break;
if (bb->loop_father->header == bb)
- {
- if (!dominated_by_p (CDI_DOMINATORS, loop->latch, bb))
- break;
-
- /* In a loop that is always entered we may proceed anyway.
- But record that we entered it and stop once we leave it
- since it might not be finite. */
- inn_loop = bb->loop_father;
- }
+ /* Record that we enter into a subloop since it might not
+ be finite. */
+ /* ??? Entering into a not always executed subloop makes
+ fill_always_executed_in quadratic in loop depth since
+ we walk those loops N times. This is not a problem
+ in practice though, see PR102253 for a worst-case testcase. */
+ inn_loop = bb->loop_father;
/* Walk the body of LOOP sorted by dominance relation. Additionally,
if a basic block S dominates the latch, then only blocks dominated