diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index afbaa216ce5..4c6d8ed90d2 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -2125,17 +2125,19 @@ loops_list::walk_loop_tree (class loop *root, unsigned flags) following while loop are impossible to be root. */ if (!root->inner) { - if (root != exclude) + if (flags & LI_INCLUDE_ROOT) this->to_visit.quick_push (root->num); return; } + else if (preorder_p && flags & LI_INCLUDE_ROOT) + this->to_visit.quick_push (root->num); class loop *aloop; - for (aloop = root; + for (aloop = root->inner; aloop->inner != NULL; aloop = aloop->inner) { - if (preorder_p && aloop != exclude) + if (preorder_p) this->to_visit.quick_push (aloop->num); continue; } @@ -2165,7 +2167,7 @@ loops_list::walk_loop_tree (class loop *root, unsigned flags) /* When visiting from innermost, we need to consider root here since the previous while loop doesn't handle it. */ - if (from_innermost_p && root != exclude) + if (from_innermost_p && flags & LI_INCLUDE_ROOT) this->to_visit.quick_push (root->num); }