[llvm] b66e33a - [Alignment][NFC] Migrate TTI::getGatherScatterOpCost to Align
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 04:08:38 PDT 2020
Author: Guillaume Chatelet
Date: 2020-06-26T11:08:27Z
New Revision: b66e33a689caec1b3fe468c3a637691b17979940
URL: https://github.com/llvm/llvm-project/commit/b66e33a689caec1b3fe468c3a637691b17979940
DIFF: https://github.com/llvm/llvm-project/commit/b66e33a689caec1b3fe468c3a637691b17979940.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
llvm/lib/Target/ARM/ARMTargetTransformInfo.h
llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
llvm/lib/Target/X86/X86TargetTransformInfo.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index c147bff29ce5..d96bc4f43a1e 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1038,8 +1038,7 @@ class TargetTransformInfo {
/// 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 @@ class TargetTransformInfo::Concept {
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 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
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 63fbd21f79c5..b85d0690da69 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -472,8 +472,7 @@ class TargetTransformInfoImplBase {
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 18c00cb04a80..5f541c34f942 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1172,7 +1172,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
assert(VF == 1 && "Can't vectorize types here.");
const Value *Mask = Args[3];
bool VarMask = !isa<Constant>(Mask);
- unsigned Alignment = cast<ConstantInt>(Args[2])->getZExtValue();
+ Align Alignment = cast<ConstantInt>(Args[2])->getAlignValue();
return ConcreteTTI->getGatherScatterOpCost(Instruction::Store,
Args[0]->getType(), Args[1],
VarMask, Alignment, CostKind,
@@ -1182,7 +1182,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
assert(VF == 1 && "Can't vectorize types here.");
const Value *Mask = Args[2];
bool VarMask = !isa<Constant>(Mask);
- unsigned Alignment = cast<ConstantInt>(Args[1])->getZExtValue();
+ Align Alignment = cast<ConstantInt>(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 e6bc1a030586..b62f445802f0 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 c8571a0c923b..c852dbb8b596 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 01d2607ca59a..5d914227c968 100644
--- a/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
+++ b/llvm/lib/Target/ARM/ARMTargetTransformInfo.h
@@ -232,8 +232,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
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 2e07ae918fbd..76df4e8e1931 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 94dcd2337758..3365c5bf1cb1 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
+++ b/llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h
@@ -123,8 +123,7 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
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<unsigned> Indices,
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index ad13d0a18c48..b3f7fd2a9d73 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<VectorType>(SrcVTy) && "Unexpected type in getGSVectorCost");
unsigned VF = cast<VectorType>(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<VectorType>(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 43d2ab941b3e..d036ffb9335b 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.h
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.h
@@ -145,7 +145,7 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
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 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
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 806999fb2391..f7d06e8fcf56 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,
More information about the llvm-commits
mailing list