[RISCV] Implement RISCVTTIImpl::getMaxVScale correctly

The comments in the existing code appear to pre-exist the standardization of the +v extension. In particular, the specification *does* provide a bound on the maximum value VLEN can take. From what I can tell, the LMUL comment was simply a misunderstanding of what this API returns.

This API returns the maximum value that vscale can take at runtime. This is used in the vectorizer to bound the largest scalable VF (e.g. LMUL in RISCV terms) which can be used without violating memory dependence.

Differential Revision: https://reviews.llvm.org/D128538
This commit is contained in:
Philip Reames 2022-06-24 16:48:21 -07:00 committed by Philip Reames
parent 27aca975b6
commit 4710e78974
1 changed files with 2 additions and 10 deletions
llvm/lib/Target/RISCV

View File

@ -132,16 +132,8 @@ bool RISCVTTIImpl::shouldExpandReduction(const IntrinsicInst *II) const {
} }
Optional<unsigned> RISCVTTIImpl::getMaxVScale() const { Optional<unsigned> RISCVTTIImpl::getMaxVScale() const {
// There is no assumption of the maximum vector length in V specification. if (ST->hasVInstructions())
// We use the value specified by users as the maximum vector length. return ST->getRealMaxVLen() / RISCV::RVVBitsPerBlock;
// 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;
return BaseT::getMaxVScale(); return BaseT::getMaxVScale();
} }