diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index bd9675f1dda59d..4d1b9e22c083f6 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2391,9 +2391,13 @@ void InnerLoopVectorizer::recordVectorLoopValueForInductionCast( if (isa(EntryVal)) return; - const SmallVectorImpl &Casts = ID.getCastInsts(); - if (Casts.empty()) + if (!CastDef) { + assert(ID.getCastInsts().empty() && + "there are casts for ID, but no CastDef"); return; + } + assert(!ID.getCastInsts().empty() && + "there is a CastDef, but no casts for ID"); // Only the first Cast instruction in the Casts vector is of interest. // The rest of the Casts (if exist) have no uses outside the // induction update chain itself.