Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -5785,6 +5785,15 @@ return Result; } + // 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. + if (MainLoopVF.isScalable()) { + LLVM_DEBUG(dbgs() << "LEV: Epilogue vectorization for scalable vectors not " + "yet supported.\n"); + return Result; + } + // Not really a cost consideration, but check for unsupported cases here to // simplify the logic. if (!isCandidateForEpilogueVectorization(*TheLoop, MainLoopVF)) { Index: llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll =================================================================== --- llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll +++ llvm/test/Transforms/LoopVectorize/optimal-epilog-vectorization-limitations.ll @@ -99,3 +99,27 @@ for.end: ; preds = %for.end.loopexit, %entry ret void } + +; Currently we cannot handle scalable vectorization factors. +; CHECK: LV: Checking a loop in "f4" +; CHECK: LEV: Epilogue vectorization for scalable vectors not yet supported. + +define void @f4(i8* %A) { +entry: + br label %for.body + +for.body: + %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] + %arrayidx = getelementptr inbounds i8, i8* %A, i64 %iv + store i8 1, i8* %arrayidx, align 1 + %iv.next = add nuw nsw i64 %iv, 1 + %exitcond = icmp ne i64 %iv.next, 1024 + br i1 %exitcond, label %for.body, label %exit, !llvm.loop !0 + +exit: + ret void +} + +!0 = !{!0, !1, !2} +!1 = !{!"llvm.loop.vectorize.width", i32 4} +!2 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}