diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -568,14 +568,12 @@ PrimaryInduction = Phi; } - // Both the PHI node itself, and the "post-increment" value feeding - // back into the PHI node may have external users. - // We can allow those uses, except if the SCEVs we have for them rely - // on predicates that only hold within the loop, since allowing the exit - // currently means re-using this SCEV outside the loop (see PR33706 for more - // details). + AllowedExit.insert(Phi); + + // Allow external uses of the "post-increment" value feeding back into + // the PHI node unless its SCEV relies on predicates that may not hold + // outside of the loop (see PR33706 for more details). if (PSE.getPredicate().isAlwaysTrue()) { - AllowedExit.insert(Phi); AllowedExit.insert(Phi->getIncomingValueForBlock(TheLoop->getLoopLatch())); }