diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -1120,6 +1120,13 @@ 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, @@ -1374,9 +1381,10 @@ /// \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 type and alignment. (see LLVM Language + /// Reference - "Vector Predication Intrinsics"). + /// Use of %evl is discouraged when that is not the case. + bool hasActiveVectorLength(Type *DataType, Align Alignment) const; struct VPLegalization { enum VPTransform { @@ -1641,6 +1649,11 @@ 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, @@ -1722,7 +1735,7 @@ 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(Type *DataType, Align Alignment) const = 0; virtual InstructionCost getInstructionLatency(const Instruction *I) = 0; virtual VPLegalization getVPLegalizationStrategy(const VPIntrinsic &PI) const = 0; @@ -2144,6 +2157,13 @@ 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 { @@ -2299,8 +2319,8 @@ return Impl.supportsScalableVectors(); } - bool hasActiveVectorLength() const override { - return Impl.hasActiveVectorLength(); + bool hasActiveVectorLength(Type *DataType, Align Alignment) const override { + return Impl.hasActiveVectorLength(DataType, Alignment); } InstructionCost getInstructionLatency(const Instruction *I) override { diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -551,6 +551,13 @@ 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 { @@ -758,7 +765,9 @@ bool supportsScalableVectors() const { return false; } - bool hasActiveVectorLength() const { return false; } + bool hasActiveVectorLength(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 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -1054,8 +1054,9 @@ return TTIImpl->supportsScalableVectors(); } -bool TargetTransformInfo::hasActiveVectorLength() const { - return TTIImpl->hasActiveVectorLength(); +bool TargetTransformInfo::hasActiveVectorLength(Type *DataType, + Align Alignment) const { + return TTIImpl->hasActiveVectorLength(DataType, Alignment); } InstructionCost diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h @@ -137,6 +137,7 @@ bool areFunctionArgsABICompatible(const Function *Caller, const Function *Callee, SmallPtrSetImpl &Args) const; + bool hasActiveVectorLength(Type *DataType, Align Alignment) const; /// @} }; diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp @@ -1337,3 +1337,8 @@ return false; } + +bool PPCTTIImpl::hasActiveVectorLength(Type *DataType, Align Alignment) const { + // TODO + return false; +}