diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 77be8cc95b6da..1726963f43e32 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -25717,9 +25717,6 @@ bool RISCVTargetLowering::isVScaleKnownToBeAPowerOfTwo() const { // We define vscale to be VLEN/RVVBitsPerBlock. VLEN is always a power // of two >= 64, and RVVBitsPerBlock is 64. Thus, vscale must be // a power of two as well. - // FIXME: This doesn't work for zve32, but that's already broken - // elsewhere for the same reason. - assert(Subtarget.getRealMinVLen() >= 64 && "zve32* unsupported"); static_assert(RISCV::RVVBitsPerBlock == 64, "RVVBitsPerBlock changed, audit needed"); return true; diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index b28c3d949c96a..073a6ccef4c93 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -296,9 +296,9 @@ cl::opt llvm::ForceTargetInstructionCost( static cl::opt ForceTargetSupportsScalableVectors( "force-target-supports-scalable-vectors", cl::init(false), cl::Hidden, - cl::desc( - "Pretend that scalable vectors are supported, even if the target does " - "not support them. This flag should only be used for testing.")); + cl::desc("Pretend that scalable vectors are supported and vscale is a " + "power of two, even if the target does " + "not support them. This flag should only be used for testing.")); static cl::opt SmallLoopCost( "small-loop-cost", cl::init(20), cl::Hidden, @@ -3387,6 +3387,10 @@ bool LoopVectorizationCostModel::isScalableVectorizationAllowed() { if (!TTI.supportsScalableVectors() && !ForceTargetSupportsScalableVectors) return false; + if (!TTI.isVScaleKnownToBeAPowerOfTwo() && + !ForceTargetSupportsScalableVectors) + return false; + if (Hints->isScalableVectorizationDisabled()) { reportVectorizationInfo("Scalable vectorization is explicitly disabled", "ScalableVectorizationDisabled", ORE, TheLoop);