Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -5772,6 +5772,11 @@ VectorizationFactor LoopVectorizationCostModel::selectEpilogueVectorizationFactor( const ElementCount MainLoopVF, const LoopVectorizationPlanner &LVP) { + // FIXME: This can be fixed for scalable vectors later, because at this stage + // the LoopVectorizer will only consider vectorizing a loop with scalable + // vectors when the loop has a hint to enable vectorization for a given VF. + assert(!MainLoopVF.isScalable() && "scalable vectors not yet supported"); + VectorizationFactor Result = VectorizationFactor::Disabled(); if (!EnableEpilogueVectorization) { LLVM_DEBUG(dbgs() << "LEV: Epilogue vectorization is disabled.\n";); @@ -9202,8 +9207,11 @@ // Consider vectorizing the epilogue too if it's profitable. VectorizationFactor EpilogueVF = - CM.selectEpilogueVectorizationFactor(VF.Width, LVP); - if (EpilogueVF.Width.isVector()) { + VF.Width.isScalable() + ? VectorizationFactor::Disabled() + : CM.selectEpilogueVectorizationFactor(VF.Width, LVP); + if (EpilogueVF != VectorizationFactor::Disabled() && + EpilogueVF.Width.isVector()) { // The first pass vectorizes the main loop and creates a scalar epilogue // to be vectorized by executing the plan (potentially with a different