-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[LV][TTI] Remove unused ReductionFlags. NFC #129858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
No in-tree targets currently use it in the preferInLoopReduction/preferPredicatedReductionSelect TTI hooks. It looks like it used to be used in LoopUtils, at least in 8ca60db, but I presume it was replaced by RecurrenceDescriptor.
|
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-backend-aarch64 Author: Luke Lau (lukel97) ChangesNo in-tree targets currently use it in the preferInLoopReduction/preferPredicatedReductionSelect TTI hooks. It looks like it used to be used in LoopUtils, at least in 8ca60db, but I presume it was replaced by RecurrenceDescriptor. Full diff: https://github.com/llvm/llvm-project/pull/129858.diff 7 Files Affected:
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index a19baaba359ea..3081379bafd06 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1766,24 +1766,13 @@ class TargetTransformInfo {
unsigned ChainSizeInBytes,
VectorType *VecTy) const;
- /// Flags describing the kind of vector reduction.
- struct ReductionFlags {
- ReductionFlags() = default;
- bool IsMaxOp =
- false; ///< If the op a min/max kind, true if it's a max operation.
- bool IsSigned = false; ///< Whether the operation is a signed int reduction.
- bool NoNaN =
- false; ///< If op is an fp min/max, whether NaNs may be present.
- };
-
/// \returns True if the targets prefers fixed width vectorization if the
/// loop vectorizer's cost-model assigns an equal cost to the fixed and
/// scalable version of the vectorized loop.
bool preferFixedOverScalableIfEqualCost() const;
/// \returns True if the target prefers reductions in loop.
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
/// \returns True if the target prefers reductions select kept in the loop
/// when tail folding. i.e.
@@ -1796,8 +1785,7 @@ class TargetTransformInfo {
/// As opposed to the normal scheme of p = phi (0, a) which allows the select
/// to be pulled out of the loop. If the select(.., add, ..) can be predicated
/// by the target, this can lead to cleaner code generation.
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
/// Return true if the loop vectorizer should consider vectorizing an
/// otherwise scalar epilogue loop.
@@ -2334,10 +2322,9 @@ class TargetTransformInfo::Concept {
unsigned ChainSizeInBytes,
VectorType *VecTy) const = 0;
virtual bool preferFixedOverScalableIfEqualCost() const = 0;
- virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
- virtual bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
+ virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty) const = 0;
+ virtual bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const = 0;
virtual bool preferEpilogueVectorization() const = 0;
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
@@ -3145,13 +3132,12 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool preferFixedOverScalableIfEqualCost() const override {
return Impl.preferFixedOverScalableIfEqualCost();
}
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferInLoopReduction(Opcode, Ty, Flags);
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const override {
+ return Impl.preferInLoopReduction(Opcode, Ty);
}
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferPredicatedReductionSelect(Opcode, Ty, Flags);
+ bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const override {
+ return Impl.preferPredicatedReductionSelect(Opcode, Ty);
}
bool preferEpilogueVectorization() const override {
return Impl.preferEpilogueVectorization();
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index a8d6dd18266bb..e1fabd2ebeec0 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1006,13 +1006,9 @@ class TargetTransformInfoImplBase {
bool preferFixedOverScalableIfEqualCost() const { return false; }
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
- return false;
- }
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const { return false; }
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return false;
}
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 1c54395909f10..72467678c4610 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1379,14 +1379,14 @@ bool TargetTransformInfo::preferFixedOverScalableIfEqualCost() const {
return TTIImpl->preferFixedOverScalableIfEqualCost();
}
-bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const {
- return TTIImpl->preferInLoopReduction(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferInLoopReduction(Opcode, Ty);
}
-bool TargetTransformInfo::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, ReductionFlags Flags) const {
- return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty);
}
bool TargetTransformInfo::preferEpilogueVectorization() const {
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index c7f8450213ae5..ac4ae96be27f4 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -416,8 +416,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc,
ElementCount VF) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return ST->hasSVE();
}
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 6b3fa04798061..2a2a46a19d7c1 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -2633,8 +2633,7 @@ void ARMTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
BaseT::getPeelingPreferences(L, SE, PP);
}
-bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
@@ -2647,8 +2646,8 @@ bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
}
}
-bool ARMTTIImpl::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
return true;
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
index 3a4f940088b2e..125866b52846c 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -223,11 +223,9 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
ArrayRef<const Value *> Args = {},
const Instruction *CxtI = nullptr);
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
bool shouldExpandReduction(const IntrinsicInst *II) const { return false; }
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 55590084492cf..9538582d03bfd 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1516,8 +1516,7 @@ class LoopVectorizationCostModel {
if (foldTailWithEVL())
return true;
return PreferPredicatedReductionSelect ||
- TTI.preferPredicatedReductionSelect(
- Opcode, PhiTy, TargetTransformInfo::ReductionFlags());
+ TTI.preferPredicatedReductionSelect(Opcode, PhiTy);
}
/// Estimate cost of an intrinsic call instruction CI if it were vectorized
@@ -4874,8 +4873,7 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
Legal->getReductionVars().find(PN)->second;
if (PreferInLoopReductions || useOrderedReductions(RdxDesc) ||
TTI.preferInLoopReduction(RdxDesc.getOpcode(),
- RdxDesc.getRecurrenceType(),
- TargetTransformInfo::ReductionFlags()))
+ RdxDesc.getRecurrenceType()))
continue;
T = RdxDesc.getRecurrenceType();
}
@@ -7042,8 +7040,7 @@ void LoopVectorizationCostModel::collectInLoopReductions() {
// want to record it as such.
unsigned Opcode = RdxDesc.getOpcode();
if (!PreferInLoopReductions && !useOrderedReductions(RdxDesc) &&
- !TTI.preferInLoopReduction(Opcode, Phi->getType(),
- TargetTransformInfo::ReductionFlags()))
+ !TTI.preferInLoopReduction(Opcode, Phi->getType()))
continue;
// Check that we can correctly put the reductions into the loop, by
|
|
@llvm/pr-subscribers-llvm-transforms Author: Luke Lau (lukel97) ChangesNo in-tree targets currently use it in the preferInLoopReduction/preferPredicatedReductionSelect TTI hooks. It looks like it used to be used in LoopUtils, at least in 8ca60db, but I presume it was replaced by RecurrenceDescriptor. Full diff: https://github.com/llvm/llvm-project/pull/129858.diff 7 Files Affected:
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index a19baaba359ea..3081379bafd06 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1766,24 +1766,13 @@ class TargetTransformInfo {
unsigned ChainSizeInBytes,
VectorType *VecTy) const;
- /// Flags describing the kind of vector reduction.
- struct ReductionFlags {
- ReductionFlags() = default;
- bool IsMaxOp =
- false; ///< If the op a min/max kind, true if it's a max operation.
- bool IsSigned = false; ///< Whether the operation is a signed int reduction.
- bool NoNaN =
- false; ///< If op is an fp min/max, whether NaNs may be present.
- };
-
/// \returns True if the targets prefers fixed width vectorization if the
/// loop vectorizer's cost-model assigns an equal cost to the fixed and
/// scalable version of the vectorized loop.
bool preferFixedOverScalableIfEqualCost() const;
/// \returns True if the target prefers reductions in loop.
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
/// \returns True if the target prefers reductions select kept in the loop
/// when tail folding. i.e.
@@ -1796,8 +1785,7 @@ class TargetTransformInfo {
/// As opposed to the normal scheme of p = phi (0, a) which allows the select
/// to be pulled out of the loop. If the select(.., add, ..) can be predicated
/// by the target, this can lead to cleaner code generation.
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
/// Return true if the loop vectorizer should consider vectorizing an
/// otherwise scalar epilogue loop.
@@ -2334,10 +2322,9 @@ class TargetTransformInfo::Concept {
unsigned ChainSizeInBytes,
VectorType *VecTy) const = 0;
virtual bool preferFixedOverScalableIfEqualCost() const = 0;
- virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
- virtual bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
+ virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty) const = 0;
+ virtual bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const = 0;
virtual bool preferEpilogueVectorization() const = 0;
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
@@ -3145,13 +3132,12 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool preferFixedOverScalableIfEqualCost() const override {
return Impl.preferFixedOverScalableIfEqualCost();
}
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferInLoopReduction(Opcode, Ty, Flags);
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const override {
+ return Impl.preferInLoopReduction(Opcode, Ty);
}
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferPredicatedReductionSelect(Opcode, Ty, Flags);
+ bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const override {
+ return Impl.preferPredicatedReductionSelect(Opcode, Ty);
}
bool preferEpilogueVectorization() const override {
return Impl.preferEpilogueVectorization();
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index a8d6dd18266bb..e1fabd2ebeec0 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1006,13 +1006,9 @@ class TargetTransformInfoImplBase {
bool preferFixedOverScalableIfEqualCost() const { return false; }
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
- return false;
- }
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const { return false; }
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return false;
}
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 1c54395909f10..72467678c4610 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1379,14 +1379,14 @@ bool TargetTransformInfo::preferFixedOverScalableIfEqualCost() const {
return TTIImpl->preferFixedOverScalableIfEqualCost();
}
-bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const {
- return TTIImpl->preferInLoopReduction(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferInLoopReduction(Opcode, Ty);
}
-bool TargetTransformInfo::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, ReductionFlags Flags) const {
- return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty);
}
bool TargetTransformInfo::preferEpilogueVectorization() const {
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index c7f8450213ae5..ac4ae96be27f4 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -416,8 +416,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc,
ElementCount VF) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return ST->hasSVE();
}
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 6b3fa04798061..2a2a46a19d7c1 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -2633,8 +2633,7 @@ void ARMTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
BaseT::getPeelingPreferences(L, SE, PP);
}
-bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
@@ -2647,8 +2646,8 @@ bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
}
}
-bool ARMTTIImpl::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
return true;
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
index 3a4f940088b2e..125866b52846c 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -223,11 +223,9 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
ArrayRef<const Value *> Args = {},
const Instruction *CxtI = nullptr);
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
bool shouldExpandReduction(const IntrinsicInst *II) const { return false; }
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 55590084492cf..9538582d03bfd 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1516,8 +1516,7 @@ class LoopVectorizationCostModel {
if (foldTailWithEVL())
return true;
return PreferPredicatedReductionSelect ||
- TTI.preferPredicatedReductionSelect(
- Opcode, PhiTy, TargetTransformInfo::ReductionFlags());
+ TTI.preferPredicatedReductionSelect(Opcode, PhiTy);
}
/// Estimate cost of an intrinsic call instruction CI if it were vectorized
@@ -4874,8 +4873,7 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
Legal->getReductionVars().find(PN)->second;
if (PreferInLoopReductions || useOrderedReductions(RdxDesc) ||
TTI.preferInLoopReduction(RdxDesc.getOpcode(),
- RdxDesc.getRecurrenceType(),
- TargetTransformInfo::ReductionFlags()))
+ RdxDesc.getRecurrenceType()))
continue;
T = RdxDesc.getRecurrenceType();
}
@@ -7042,8 +7040,7 @@ void LoopVectorizationCostModel::collectInLoopReductions() {
// want to record it as such.
unsigned Opcode = RdxDesc.getOpcode();
if (!PreferInLoopReductions && !useOrderedReductions(RdxDesc) &&
- !TTI.preferInLoopReduction(Opcode, Phi->getType(),
- TargetTransformInfo::ReductionFlags()))
+ !TTI.preferInLoopReduction(Opcode, Phi->getType()))
continue;
// Check that we can correctly put the reductions into the loop, by
|
|
@llvm/pr-subscribers-llvm-analysis Author: Luke Lau (lukel97) ChangesNo in-tree targets currently use it in the preferInLoopReduction/preferPredicatedReductionSelect TTI hooks. It looks like it used to be used in LoopUtils, at least in 8ca60db, but I presume it was replaced by RecurrenceDescriptor. Full diff: https://github.com/llvm/llvm-project/pull/129858.diff 7 Files Affected:
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index a19baaba359ea..3081379bafd06 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1766,24 +1766,13 @@ class TargetTransformInfo {
unsigned ChainSizeInBytes,
VectorType *VecTy) const;
- /// Flags describing the kind of vector reduction.
- struct ReductionFlags {
- ReductionFlags() = default;
- bool IsMaxOp =
- false; ///< If the op a min/max kind, true if it's a max operation.
- bool IsSigned = false; ///< Whether the operation is a signed int reduction.
- bool NoNaN =
- false; ///< If op is an fp min/max, whether NaNs may be present.
- };
-
/// \returns True if the targets prefers fixed width vectorization if the
/// loop vectorizer's cost-model assigns an equal cost to the fixed and
/// scalable version of the vectorized loop.
bool preferFixedOverScalableIfEqualCost() const;
/// \returns True if the target prefers reductions in loop.
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
/// \returns True if the target prefers reductions select kept in the loop
/// when tail folding. i.e.
@@ -1796,8 +1785,7 @@ class TargetTransformInfo {
/// As opposed to the normal scheme of p = phi (0, a) which allows the select
/// to be pulled out of the loop. If the select(.., add, ..) can be predicated
/// by the target, this can lead to cleaner code generation.
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
/// Return true if the loop vectorizer should consider vectorizing an
/// otherwise scalar epilogue loop.
@@ -2334,10 +2322,9 @@ class TargetTransformInfo::Concept {
unsigned ChainSizeInBytes,
VectorType *VecTy) const = 0;
virtual bool preferFixedOverScalableIfEqualCost() const = 0;
- virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
- virtual bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
+ virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty) const = 0;
+ virtual bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const = 0;
virtual bool preferEpilogueVectorization() const = 0;
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
@@ -3145,13 +3132,12 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool preferFixedOverScalableIfEqualCost() const override {
return Impl.preferFixedOverScalableIfEqualCost();
}
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferInLoopReduction(Opcode, Ty, Flags);
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const override {
+ return Impl.preferInLoopReduction(Opcode, Ty);
}
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferPredicatedReductionSelect(Opcode, Ty, Flags);
+ bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const override {
+ return Impl.preferPredicatedReductionSelect(Opcode, Ty);
}
bool preferEpilogueVectorization() const override {
return Impl.preferEpilogueVectorization();
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index a8d6dd18266bb..e1fabd2ebeec0 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1006,13 +1006,9 @@ class TargetTransformInfoImplBase {
bool preferFixedOverScalableIfEqualCost() const { return false; }
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
- return false;
- }
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const { return false; }
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return false;
}
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 1c54395909f10..72467678c4610 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1379,14 +1379,14 @@ bool TargetTransformInfo::preferFixedOverScalableIfEqualCost() const {
return TTIImpl->preferFixedOverScalableIfEqualCost();
}
-bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const {
- return TTIImpl->preferInLoopReduction(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferInLoopReduction(Opcode, Ty);
}
-bool TargetTransformInfo::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, ReductionFlags Flags) const {
- return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty);
}
bool TargetTransformInfo::preferEpilogueVectorization() const {
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index c7f8450213ae5..ac4ae96be27f4 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -416,8 +416,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc,
ElementCount VF) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return ST->hasSVE();
}
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 6b3fa04798061..2a2a46a19d7c1 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -2633,8 +2633,7 @@ void ARMTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
BaseT::getPeelingPreferences(L, SE, PP);
}
-bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
@@ -2647,8 +2646,8 @@ bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
}
}
-bool ARMTTIImpl::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
return true;
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
index 3a4f940088b2e..125866b52846c 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -223,11 +223,9 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
ArrayRef<const Value *> Args = {},
const Instruction *CxtI = nullptr);
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
bool shouldExpandReduction(const IntrinsicInst *II) const { return false; }
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 55590084492cf..9538582d03bfd 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1516,8 +1516,7 @@ class LoopVectorizationCostModel {
if (foldTailWithEVL())
return true;
return PreferPredicatedReductionSelect ||
- TTI.preferPredicatedReductionSelect(
- Opcode, PhiTy, TargetTransformInfo::ReductionFlags());
+ TTI.preferPredicatedReductionSelect(Opcode, PhiTy);
}
/// Estimate cost of an intrinsic call instruction CI if it were vectorized
@@ -4874,8 +4873,7 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
Legal->getReductionVars().find(PN)->second;
if (PreferInLoopReductions || useOrderedReductions(RdxDesc) ||
TTI.preferInLoopReduction(RdxDesc.getOpcode(),
- RdxDesc.getRecurrenceType(),
- TargetTransformInfo::ReductionFlags()))
+ RdxDesc.getRecurrenceType()))
continue;
T = RdxDesc.getRecurrenceType();
}
@@ -7042,8 +7040,7 @@ void LoopVectorizationCostModel::collectInLoopReductions() {
// want to record it as such.
unsigned Opcode = RdxDesc.getOpcode();
if (!PreferInLoopReductions && !useOrderedReductions(RdxDesc) &&
- !TTI.preferInLoopReduction(Opcode, Phi->getType(),
- TargetTransformInfo::ReductionFlags()))
+ !TTI.preferInLoopReduction(Opcode, Phi->getType()))
continue;
// Check that we can correctly put the reductions into the loop, by
|
|
@llvm/pr-subscribers-backend-arm Author: Luke Lau (lukel97) ChangesNo in-tree targets currently use it in the preferInLoopReduction/preferPredicatedReductionSelect TTI hooks. It looks like it used to be used in LoopUtils, at least in 8ca60db, but I presume it was replaced by RecurrenceDescriptor. Full diff: https://github.com/llvm/llvm-project/pull/129858.diff 7 Files Affected:
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index a19baaba359ea..3081379bafd06 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1766,24 +1766,13 @@ class TargetTransformInfo {
unsigned ChainSizeInBytes,
VectorType *VecTy) const;
- /// Flags describing the kind of vector reduction.
- struct ReductionFlags {
- ReductionFlags() = default;
- bool IsMaxOp =
- false; ///< If the op a min/max kind, true if it's a max operation.
- bool IsSigned = false; ///< Whether the operation is a signed int reduction.
- bool NoNaN =
- false; ///< If op is an fp min/max, whether NaNs may be present.
- };
-
/// \returns True if the targets prefers fixed width vectorization if the
/// loop vectorizer's cost-model assigns an equal cost to the fixed and
/// scalable version of the vectorized loop.
bool preferFixedOverScalableIfEqualCost() const;
/// \returns True if the target prefers reductions in loop.
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
/// \returns True if the target prefers reductions select kept in the loop
/// when tail folding. i.e.
@@ -1796,8 +1785,7 @@ class TargetTransformInfo {
/// As opposed to the normal scheme of p = phi (0, a) which allows the select
/// to be pulled out of the loop. If the select(.., add, ..) can be predicated
/// by the target, this can lead to cleaner code generation.
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
/// Return true if the loop vectorizer should consider vectorizing an
/// otherwise scalar epilogue loop.
@@ -2334,10 +2322,9 @@ class TargetTransformInfo::Concept {
unsigned ChainSizeInBytes,
VectorType *VecTy) const = 0;
virtual bool preferFixedOverScalableIfEqualCost() const = 0;
- virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
- virtual bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags) const = 0;
+ virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty) const = 0;
+ virtual bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const = 0;
virtual bool preferEpilogueVectorization() const = 0;
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
@@ -3145,13 +3132,12 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool preferFixedOverScalableIfEqualCost() const override {
return Impl.preferFixedOverScalableIfEqualCost();
}
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferInLoopReduction(Opcode, Ty, Flags);
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const override {
+ return Impl.preferInLoopReduction(Opcode, Ty);
}
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const override {
- return Impl.preferPredicatedReductionSelect(Opcode, Ty, Flags);
+ bool preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const override {
+ return Impl.preferPredicatedReductionSelect(Opcode, Ty);
}
bool preferEpilogueVectorization() const override {
return Impl.preferEpilogueVectorization();
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index a8d6dd18266bb..e1fabd2ebeec0 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1006,13 +1006,9 @@ class TargetTransformInfoImplBase {
bool preferFixedOverScalableIfEqualCost() const { return false; }
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
- return false;
- }
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const { return false; }
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return false;
}
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 1c54395909f10..72467678c4610 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1379,14 +1379,14 @@ bool TargetTransformInfo::preferFixedOverScalableIfEqualCost() const {
return TTIImpl->preferFixedOverScalableIfEqualCost();
}
-bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode, Type *Ty,
- ReductionFlags Flags) const {
- return TTIImpl->preferInLoopReduction(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferInLoopReduction(Opcode, Ty);
}
-bool TargetTransformInfo::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, ReductionFlags Flags) const {
- return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty, Flags);
+bool TargetTransformInfo::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
+ return TTIImpl->preferPredicatedReductionSelect(Opcode, Ty);
}
bool TargetTransformInfo::preferEpilogueVectorization() const {
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
index c7f8450213ae5..ac4ae96be27f4 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
@@ -416,8 +416,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc,
ElementCount VF) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {
return ST->hasSVE();
}
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
index 6b3fa04798061..2a2a46a19d7c1 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
@@ -2633,8 +2633,7 @@ void ARMTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
BaseT::getPeelingPreferences(L, SE, PP);
}
-bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
@@ -2647,8 +2646,8 @@ bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty,
}
}
-bool ARMTTIImpl::preferPredicatedReductionSelect(
- unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const {
+bool ARMTTIImpl::preferPredicatedReductionSelect(unsigned Opcode,
+ Type *Ty) const {
if (!ST->hasMVEIntegerOps())
return false;
return true;
diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
index 3a4f940088b2e..125866b52846c 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -223,11 +223,9 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
ArrayRef<const Value *> Args = {},
const Instruction *CxtI = nullptr);
- bool preferInLoopReduction(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
- bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty,
- TTI::ReductionFlags Flags) const;
+ bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
bool shouldExpandReduction(const IntrinsicInst *II) const { return false; }
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 55590084492cf..9538582d03bfd 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1516,8 +1516,7 @@ class LoopVectorizationCostModel {
if (foldTailWithEVL())
return true;
return PreferPredicatedReductionSelect ||
- TTI.preferPredicatedReductionSelect(
- Opcode, PhiTy, TargetTransformInfo::ReductionFlags());
+ TTI.preferPredicatedReductionSelect(Opcode, PhiTy);
}
/// Estimate cost of an intrinsic call instruction CI if it were vectorized
@@ -4874,8 +4873,7 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
Legal->getReductionVars().find(PN)->second;
if (PreferInLoopReductions || useOrderedReductions(RdxDesc) ||
TTI.preferInLoopReduction(RdxDesc.getOpcode(),
- RdxDesc.getRecurrenceType(),
- TargetTransformInfo::ReductionFlags()))
+ RdxDesc.getRecurrenceType()))
continue;
T = RdxDesc.getRecurrenceType();
}
@@ -7042,8 +7040,7 @@ void LoopVectorizationCostModel::collectInLoopReductions() {
// want to record it as such.
unsigned Opcode = RdxDesc.getOpcode();
if (!PreferInLoopReductions && !useOrderedReductions(RdxDesc) &&
- !TTI.preferInLoopReduction(Opcode, Phi->getType(),
- TargetTransformInfo::ReductionFlags()))
+ !TTI.preferInLoopReduction(Opcode, Phi->getType()))
continue;
// Check that we can correctly put the reductions into the loop, by
|
davemgreen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fhahn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/14031 Here is the relevant piece of the build log for the reference |
No in-tree targets currently use it in the preferInLoopReduction/preferPredicatedReductionSelect TTI hooks. It looks like it used to be used in LoopUtils, at least in 8ca60db, but I presume it was replaced by RecurrenceDescriptor.