[llvm] 703130f - [TTI] Change TargetTransformInfo::getMinimumVF to return ElementCount
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 01:09:23 PST 2021
Author: Sander de Smalen
Date: 2021-02-11T09:08:48Z
New Revision: 703130fb016ac21b0a4537b0c8cf66ac15e8a7ac
URL: https://github.com/llvm/llvm-project/commit/703130fb016ac21b0a4537b0c8cf66ac15e8a7ac
DIFF: https://github.com/llvm/llvm-project/commit/703130fb016ac21b0a4537b0c8cf66ac15e8a7ac.diff
LOG: [TTI] Change TargetTransformInfo::getMinimumVF to return ElementCount
This will be needed in the loop-vectorizer where the minimum VF
requested may be a scalable VF. getMinimumVF now takes an additional
operand 'IsScalableVF' that indicates whether a scalable VF is required.
Reviewed By: kparzysz, rampitec
Differential Revision: https://reviews.llvm.org/D96020
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 992e15500d9c..b2eb9864fe0b 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -945,7 +945,8 @@ class TargetTransformInfo {
/// \return The minimum vectorization factor for types of given element
/// bit width, or 0 if there is no minimum VF. The returned value only
/// applies when shouldMaximizeVectorBandwidth returns true.
- unsigned getMinimumVF(unsigned ElemWidth) const;
+ /// If IsScalable is true, the returned ElementCount must be a scalable VF.
+ ElementCount getMinimumVF(unsigned ElemWidth, bool IsScalable) const;
/// \return The maximum vectorization factor for types of given element
/// bit width and opcode, or 0 if there is no maximum VF.
@@ -1523,7 +1524,8 @@ class TargetTransformInfo::Concept {
virtual unsigned getMinVectorRegisterBitWidth() = 0;
virtual Optional<unsigned> getMaxVScale() const = 0;
virtual bool shouldMaximizeVectorBandwidth(bool OptSize) const = 0;
- virtual unsigned getMinimumVF(unsigned ElemWidth) const = 0;
+ virtual ElementCount getMinimumVF(unsigned ElemWidth,
+ bool IsScalable) const = 0;
virtual unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const = 0;
virtual bool shouldConsiderAddressTypePromotion(
const Instruction &I, bool &AllowPromotionWithoutCommonHeader) = 0;
@@ -1951,8 +1953,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool shouldMaximizeVectorBandwidth(bool OptSize) const override {
return Impl.shouldMaximizeVectorBandwidth(OptSize);
}
- unsigned getMinimumVF(unsigned ElemWidth) const override {
- return Impl.getMinimumVF(ElemWidth);
+ ElementCount getMinimumVF(unsigned ElemWidth,
+ bool IsScalable) const override {
+ return Impl.getMinimumVF(ElemWidth, IsScalable);
}
unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const override {
return Impl.getMaximumVF(ElemWidth, Opcode);
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index a4f9e1d7b982..f0443fb1d734 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -374,7 +374,9 @@ class TargetTransformInfoImplBase {
bool shouldMaximizeVectorBandwidth(bool OptSize) const { return false; }
- unsigned getMinimumVF(unsigned ElemWidth) const { return 0; }
+ ElementCount getMinimumVF(unsigned ElemWidth, bool IsScalable) const {
+ return ElementCount::get(0, IsScalable);
+ }
unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const { return 0; }
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index e376d42c15bd..ee1573098ed7 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -640,8 +640,9 @@ bool TargetTransformInfo::shouldMaximizeVectorBandwidth(bool OptSize) const {
return TTIImpl->shouldMaximizeVectorBandwidth(OptSize);
}
-unsigned TargetTransformInfo::getMinimumVF(unsigned ElemWidth) const {
- return TTIImpl->getMinimumVF(ElemWidth);
+ElementCount TargetTransformInfo::getMinimumVF(unsigned ElemWidth,
+ bool IsScalable) const {
+ return TTIImpl->getMinimumVF(ElemWidth, IsScalable);
}
unsigned TargetTransformInfo::getMaximumVF(unsigned ElemWidth,
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
index 1cefa6a04640..af7bc4682249 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
@@ -104,8 +104,10 @@ unsigned HexagonTTIImpl::getMinVectorRegisterBitWidth() const {
return useHVX() ? ST.getVectorLength()*8 : 32;
}
-unsigned HexagonTTIImpl::getMinimumVF(unsigned ElemWidth) const {
- return (8 * ST.getVectorLength()) / ElemWidth;
+ElementCount HexagonTTIImpl::getMinimumVF(unsigned ElemWidth,
+ bool IsScalable) const {
+ assert(!IsScalable && "Scalable VFs are not supported for Hexagon");
+ return ElementCount::getFixed((8 * ST.getVectorLength()) / ElemWidth);
}
unsigned HexagonTTIImpl::getScalarizationOverhead(VectorType *Ty,
diff --git a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
index 835358d3fed0..dc075d6147b6 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
+++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
@@ -82,7 +82,7 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
unsigned getMaxInterleaveFactor(unsigned VF);
unsigned getRegisterBitWidth(bool Vector) const;
unsigned getMinVectorRegisterBitWidth() const;
- unsigned getMinimumVF(unsigned ElemWidth) const;
+ ElementCount getMinimumVF(unsigned ElemWidth, bool IsScalable) const;
bool shouldMaximizeVectorBandwidth(bool OptSize) const {
return true;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 71b626e8683f..cb7bc82fb042 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5812,7 +5812,8 @@ LoopVectorizationCostModel::computeFeasibleMaxVF(unsigned ConstTripCount,
break;
}
}
- if (auto MinVF = ElementCount::getFixed(TTI.getMinimumVF(SmallestType))) {
+ if (ElementCount MinVF =
+ TTI.getMinimumVF(SmallestType, /*IsScalable=*/false)) {
if (ElementCount::isKnownLT(MaxVF, MinVF)) {
LLVM_DEBUG(dbgs() << "LV: Overriding calculated MaxVF(" << MaxVF
<< ") with target's minimum: " << MinVF << '\n');
More information about the llvm-commits
mailing list