diff --git a/llvm/lib/Transforms/Vectorize/VPlanCFG.h b/llvm/lib/Transforms/Vectorize/VPlanCFG.h --- a/llvm/lib/Transforms/Vectorize/VPlanCFG.h +++ b/llvm/lib/Transforms/Vectorize/VPlanCFG.h @@ -144,7 +144,8 @@ /// entry node of VPRegionBlocks. Exit blocks of a region implicitly have their /// parent region's successors. This ensures all blocks in a region are visited /// before any blocks in a successor region when doing a reverse post-order -// traversal of the graph. +// traversal of the graph. Region blocks themselves are not directly connected +// to their successors. template class VPAllSuccessorsIterator : public iterator_facade_base, @@ -166,9 +167,8 @@ /// both the const and non-const operator* implementations. template static T1 deref(T1 Block, unsigned SuccIdx) { if (auto *R = dyn_cast(Block)) { - if (SuccIdx == 0) - return R->getEntry(); - SuccIdx--; + assert(SuccIdx == 0); + return R->getEntry(); } // For exit blocks, use the next parent region with successors. @@ -194,7 +194,7 @@ : Block->getNumSuccessors(); if (auto *R = dyn_cast(Block)) - return {R, NumSuccessors + 1}; + return {R, 1}; return {Block, NumSuccessors}; }