Index: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -132,16 +132,8 @@ } Optional RISCVTTIImpl::getMaxVScale() const { - // There is no assumption of the maximum vector length in V specification. - // We use the value specified by users as the maximum vector length. - // This function will use the assumed maximum vector length to get the - // maximum vscale for LoopVectorizer. - // If users do not specify the maximum vector length, we have no way to - // know whether the LoopVectorizer is safe to do or not. - // We only consider to use single vector register (LMUL = 1) to vectorize. - unsigned MaxVectorSizeInBits = ST->getMaxRVVVectorSizeInBits(); - if (ST->hasVInstructions() && MaxVectorSizeInBits != 0) - return MaxVectorSizeInBits / RISCV::RVVBitsPerBlock; + if (ST->hasVInstructions()) + return ST->getRealMaxVLen() / RISCV::RVVBitsPerBlock; return BaseT::getMaxVScale(); }