diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp index 789047a2a28e7..5882b2b5466d9 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp @@ -1527,6 +1527,11 @@ bool LoopVectorizationLegality::canVectorizeWithIfConvert() { if (!CurrI || !TheLoop->contains(CurrI)) { // If operands from outside the loop may be poison then Ptr may also // be poison. + assert((TheLoop->getLoopPredecessor() && + TheLoop->getLoopPredecessor()->getTerminator()) && + "No loop predecessor/pred terminator found while checking " + "out of loop instruction for poison"); + if (!isGuaranteedNotToBePoison(CurrV, AC, TheLoop->getLoopPredecessor() ->getTerminator()