[llvm] dfcfd14 - [VP] getVPMemoryOpCost interface
Bardia Mahjour via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 08:27:37 PST 2021
Author: Bardia Mahjour
Date: 2021-12-06T11:27:07-05:00
New Revision: dfcfd14070bd75b33f57026ef0d1d1b83c64d787
URL: https://github.com/llvm/llvm-project/commit/dfcfd14070bd75b33f57026ef0d1d1b83c64d787
DIFF: https://github.com/llvm/llvm-project/commit/dfcfd14070bd75b33f57026ef0d1d1b83c64d787.diff
LOG: [VP] getVPMemoryOpCost interface
Added TTI queries for the cost of a VP Memory operation, and added Opcode,
DataType and Alignment to the hasActiveVectorLength() interface.
Reviewed By: Roland Froese
Differential Revision: https://reviews.llvm.org/D109416
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index 170d6b8f35ff0..8d4d7e69f2dc4 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1137,6 +1137,13 @@ class TargetTransformInfo {
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
const Instruction *I = nullptr) const;
+ /// \return The cost of VP Load and Store instructions.
+ InstructionCost
+ getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
+ unsigned AddressSpace,
+ TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
+ const Instruction *I = nullptr) const;
+
/// \return The cost of masked Load and Store instructions.
InstructionCost getMaskedMemoryOpCost(
unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
@@ -1391,9 +1398,11 @@ class TargetTransformInfo {
/// \name Vector Predication Information
/// @{
/// Whether the target supports the %evl parameter of VP intrinsic efficiently
- /// in hardware. (see LLVM Language Reference - "Vector Predication
- /// Intrinsics") Use of %evl is discouraged when that is not the case.
- bool hasActiveVectorLength() const;
+ /// in hardware, for the given opcode and type/alignment. (see LLVM Language
+ /// Reference - "Vector Predication Intrinsics").
+ /// Use of %evl is discouraged when that is not the case.
+ bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
+ Align Alignment) const;
struct VPLegalization {
enum VPTransform {
@@ -1667,6 +1676,11 @@ class TargetTransformInfo::Concept {
unsigned AddressSpace,
TTI::TargetCostKind CostKind,
const Instruction *I) = 0;
+ virtual InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src,
+ Align Alignment,
+ unsigned AddressSpace,
+ TTI::TargetCostKind CostKind,
+ const Instruction *I) = 0;
virtual InstructionCost
getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace,
@@ -1748,7 +1762,8 @@ class TargetTransformInfo::Concept {
virtual bool shouldExpandReduction(const IntrinsicInst *II) const = 0;
virtual unsigned getGISelRematGlobalCost() const = 0;
virtual bool supportsScalableVectors() const = 0;
- virtual bool hasActiveVectorLength() const = 0;
+ virtual bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
+ Align Alignment) const = 0;
virtual InstructionCost getInstructionLatency(const Instruction *I) = 0;
virtual VPLegalization
getVPLegalizationStrategy(const VPIntrinsic &PI) const = 0;
@@ -2185,6 +2200,13 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
CostKind, I);
}
+ InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
+ unsigned AddressSpace,
+ TTI::TargetCostKind CostKind,
+ const Instruction *I) override {
+ return Impl.getVPMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
+ CostKind, I);
+ }
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
Align Alignment, unsigned AddressSpace,
TTI::TargetCostKind CostKind) override {
@@ -2340,8 +2362,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
return Impl.supportsScalableVectors();
}
- bool hasActiveVectorLength() const override {
- return Impl.hasActiveVectorLength();
+ bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
+ Align Alignment) const override {
+ return Impl.hasActiveVectorLength(Opcode, DataType, Alignment);
}
InstructionCost getInstructionLatency(const Instruction *I) override {
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 05ef2495475fc..0fafadf05be17 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -564,6 +564,13 @@ class TargetTransformInfoImplBase {
return 1;
}
+ InstructionCost getVPMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
+ unsigned AddressSpace,
+ TTI::TargetCostKind CostKind,
+ const Instruction *I) const {
+ return 1;
+ }
+
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
Align Alignment, unsigned AddressSpace,
TTI::TargetCostKind CostKind) const {
@@ -772,7 +779,10 @@ class TargetTransformInfoImplBase {
bool supportsScalableVectors() const { return false; }
- bool hasActiveVectorLength() const { return false; }
+ bool hasActiveVectorLength(unsigned Opcode, Type *DataType,
+ Align Alignment) const {
+ return false;
+ }
TargetTransformInfo::VPLegalization
getVPLegalizationStrategy(const VPIntrinsic &PI) const {
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 5067f493f02de..98f31e4dd2a5b 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1072,8 +1072,9 @@ bool TargetTransformInfo::supportsScalableVectors() const {
return TTIImpl->supportsScalableVectors();
}
-bool TargetTransformInfo::hasActiveVectorLength() const {
- return TTIImpl->hasActiveVectorLength();
+bool TargetTransformInfo::hasActiveVectorLength(unsigned Opcode, Type *DataType,
+ Align Alignment) const {
+ return TTIImpl->hasActiveVectorLength(Opcode, DataType, Alignment);
}
InstructionCost
More information about the llvm-commits
mailing list