From: Guillaume Chatelet Date: Fri, 26 Jun 2020 11:08:27 +0000 (+0000) Subject: [Alignment][NFC] Migrate TTI::getGatherScatterOpCost to Align X-Git-Tag: llvmorg-12-init~1824 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b66e33a689caec1b3fe468c3a637691b17979940;p=platform%2Fupstream%2Fllvm.git [Alignment][NFC] Migrate TTI::getGatherScatterOpCost to Align This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Differential Revision: https://reviews.llvm.org/D82577 --- diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h index c147bff..d96bc4f 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfo.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h @@ -1038,8 +1038,7 @@ public: /// load/store to transform or the call to the gather/scatter intrinsic int getGatherScatterOpCost( unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, - TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, + Align Alignment, TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, const Instruction *I = nullptr) const; /// \return The cost of the interleaved memory operation. @@ -1431,7 +1430,7 @@ public: TTI::TargetCostKind CostKind) = 0; virtual int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr) = 0; @@ -1847,7 +1846,7 @@ public: CostKind); } int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, - bool VariableMask, unsigned Alignment, + bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr) override { return Impl.getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index 63fbd21..b85d069 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -472,8 +472,7 @@ public: unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, - TTI::TargetCostKind CostKind, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr) { return 1; } diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h index 18c00cb..5f541c3 100644 --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -1172,7 +1172,7 @@ public: assert(VF == 1 && "Can't vectorize types here."); const Value *Mask = Args[3]; bool VarMask = !isa(Mask); - unsigned Alignment = cast(Args[2])->getZExtValue(); + Align Alignment = cast(Args[2])->getAlignValue(); return ConcreteTTI->getGatherScatterOpCost(Instruction::Store, Args[0]->getType(), Args[1], VarMask, Alignment, CostKind, @@ -1182,7 +1182,7 @@ public: assert(VF == 1 && "Can't vectorize types here."); const Value *Mask = Args[2]; bool VarMask = !isa(Mask); - unsigned Alignment = cast(Args[1])->getZExtValue(); + Align Alignment = cast(Args[1])->getAlignValue(); return ConcreteTTI->getGatherScatterOpCost( Instruction::Load, RetTy, Args[0], VarMask, Alignment, CostKind, I); } diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp index e6bc1a0..b62f445 100644 --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -767,12 +767,9 @@ int TargetTransformInfo::getMaskedMemoryOpCost( return Cost; } -int TargetTransformInfo::getGatherScatterOpCost(unsigned Opcode, Type *DataTy, - const Value *Ptr, - bool VariableMask, - unsigned Alignment, - TTI::TargetCostKind CostKind, - const Instruction *I) const { +int TargetTransformInfo::getGatherScatterOpCost( + unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I) const { int Cost = TTIImpl->getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, Alignment, CostKind, I); assert(Cost >= 0 && "TTI should not produce negative costs!"); diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp index c8571a0..c852dbb 100644 --- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp +++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp @@ -952,7 +952,7 @@ int ARMTTIImpl::getInterleavedMemoryOpCost( unsigned ARMTTIImpl::getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I) { using namespace PatternMatch; diff --git a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h index 01d2607..5d91422 100644 --- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h +++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h @@ -232,8 +232,7 @@ public: unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, - TTI::TargetCostKind CostKind, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr); bool isLoweredToCall(const Function *F); diff --git a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp index 2e07ae9..76df4e8 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp @@ -215,7 +215,7 @@ unsigned HexagonTTIImpl::getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, unsigned HexagonTTIImpl::getGatherScatterOpCost( unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, TTI::TargetCostKind CostKind, const Instruction *I) { + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I) { return BaseT::getGatherScatterOpCost(Opcode, DataTy, Ptr, VariableMask, Alignment, CostKind, I); } diff --git a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h index 94dcd23..3365c5b 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h @@ -123,8 +123,7 @@ public: Type *SubTp); unsigned getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, - TTI::TargetCostKind CostKind, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I); unsigned getInterleavedMemoryOpCost( unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef Indices, diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index ad13d0a..b3f7fd2 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -3847,7 +3847,7 @@ X86TTIImpl::getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind) { // Return an average cost of Gather / Scatter instruction, maybe improved later int X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy, const Value *Ptr, - unsigned Alignment, unsigned AddressSpace) { + Align Alignment, unsigned AddressSpace) { assert(isa(SrcVTy) && "Unexpected type in getGSVectorCost"); unsigned VF = cast(SrcVTy)->getNumElements(); @@ -3919,7 +3919,7 @@ int X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy, const Value *Ptr, /// AddressSpace - pointer[s] address space. /// int X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy, - bool VariableMask, unsigned Alignment, + bool VariableMask, Align Alignment, unsigned AddressSpace) { unsigned VF = cast(SrcVTy)->getNumElements(); APInt DemandedElts = APInt::getAllOnesValue(VF); @@ -3961,7 +3961,7 @@ int X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy, /// Calculate the cost of Gather / Scatter operation int X86TTIImpl::getGatherScatterOpCost(unsigned Opcode, Type *SrcVTy, const Value *Ptr, bool VariableMask, - unsigned Alignment, + Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I = nullptr) { diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.h b/llvm/lib/Target/X86/X86TargetTransformInfo.h index 43d2ab9..d036ffb 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.h +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h @@ -145,7 +145,7 @@ public: unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency); int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, - bool VariableMask, unsigned Alignment, + bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I); int getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, @@ -226,9 +226,9 @@ public: private: int getGSScalarCost(unsigned Opcode, Type *DataTy, bool VariableMask, - unsigned Alignment, unsigned AddressSpace); + Align Alignment, unsigned AddressSpace); int getGSVectorCost(unsigned Opcode, Type *DataTy, const Value *Ptr, - unsigned Alignment, unsigned AddressSpace); + Align Alignment, unsigned AddressSpace); /// @} }; diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 806999f..f7d06e8 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -5935,10 +5935,9 @@ unsigned LoopVectorizationCostModel::getGatherScatterCost(Instruction *I, const Value *Ptr = getLoadStorePointerOperand(I); return TTI.getAddressComputationCost(VectorTy) + - TTI.getGatherScatterOpCost(I->getOpcode(), VectorTy, Ptr, - Legal->isMaskRequired(I), Alignment.value(), - TargetTransformInfo::TCK_RecipThroughput, - I); + TTI.getGatherScatterOpCost( + I->getOpcode(), VectorTy, Ptr, Legal->isMaskRequired(I), Alignment, + TargetTransformInfo::TCK_RecipThroughput, I); } unsigned LoopVectorizationCostModel::getInterleaveGroupCost(Instruction *I,