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 @@ -1137,6 +1137,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, @@ -1391,9 +1398,11 @@ /// \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 @@ 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 @@ 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 @@ 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 @@ 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 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -564,6 +564,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 { @@ -772,7 +779,10 @@ 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 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -1072,8 +1072,9 @@ 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