[llvm] 27b4e69 - [NFC] Replace MaybeAlign with Align in TargetTransformInfo.
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon May 18 19:26:08 PDT 2020
Author: Eli Friedman
Date: 2020-05-18T19:25:49-07:00
New Revision: 27b4e6931d0f2f16293e6abface7da25fb731e14
URL: https://github.com/llvm/llvm-project/commit/27b4e6931d0f2f16293e6abface7da25fb731e14
DIFF: https://github.com/llvm/llvm-project/commit/27b4e6931d0f2f16293e6abface7da25fb731e14.diff
LOG: [NFC] Replace MaybeAlign with Align in TargetTransformInfo.
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index e5f2c53c910f..c0aba2d0817d 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -542,9 +542,9 @@ class TargetTransformInfo {
bool shouldFavorBackedgeIndex(const Loop *L) const;
/// Return true if the target supports masked store.
- bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) const;
+ bool isLegalMaskedStore(Type *DataType, Align Alignment) const;
/// Return true if the target supports masked load.
- bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment) const;
+ bool isLegalMaskedLoad(Type *DataType, Align Alignment) const;
/// Return true if the target supports nontemporal store.
bool isLegalNTStore(Type *DataType, Align Alignment) const;
@@ -552,9 +552,9 @@ class TargetTransformInfo {
bool isLegalNTLoad(Type *DataType, Align Alignment) const;
/// Return true if the target supports masked scatter.
- bool isLegalMaskedScatter(Type *DataType, MaybeAlign Alignment) const;
+ bool isLegalMaskedScatter(Type *DataType, Align Alignment) const;
/// Return true if the target supports masked gather.
- bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment) const;
+ bool isLegalMaskedGather(Type *DataType, Align Alignment) const;
/// Return true if the target supports masked compress store.
bool isLegalMaskedCompressStore(Type *DataType) const;
@@ -931,7 +931,7 @@ class TargetTransformInfo {
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index = -1) const;
/// \return The cost of Load and Store instructions.
- int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
+ int getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace,
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
const Instruction *I = nullptr) const;
@@ -1243,12 +1243,12 @@ class TargetTransformInfo::Concept {
TargetLibraryInfo *LibInfo) = 0;
virtual bool shouldFavorPostInc() const = 0;
virtual bool shouldFavorBackedgeIndex(const Loop *L) const = 0;
- virtual bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) = 0;
- virtual bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment) = 0;
+ virtual bool isLegalMaskedStore(Type *DataType, Align Alignment) = 0;
+ virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment) = 0;
virtual bool isLegalNTStore(Type *DataType, Align Alignment) = 0;
virtual bool isLegalNTLoad(Type *DataType, Align Alignment) = 0;
- virtual bool isLegalMaskedScatter(Type *DataType, MaybeAlign Alignment) = 0;
- virtual bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment) = 0;
+ virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) = 0;
+ virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) = 0;
virtual bool isLegalMaskedCompressStore(Type *DataType) = 0;
virtual bool isLegalMaskedExpandLoad(Type *DataType) = 0;
virtual bool hasDivRemOp(Type *DataType, bool IsSigned) = 0;
@@ -1356,7 +1356,7 @@ class TargetTransformInfo::Concept {
const Instruction *I) = 0;
virtual int getVectorInstrCost(unsigned Opcode, Type *Val,
unsigned Index) = 0;
- virtual int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
+ virtual int getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace,
TTI::TargetCostKind CostKind,
const Instruction *I) = 0;
@@ -1559,10 +1559,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool shouldFavorBackedgeIndex(const Loop *L) const override {
return Impl.shouldFavorBackedgeIndex(L);
}
- bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) override {
+ bool isLegalMaskedStore(Type *DataType, Align Alignment) override {
return Impl.isLegalMaskedStore(DataType, Alignment);
}
- bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment) override {
+ bool isLegalMaskedLoad(Type *DataType, Align Alignment) override {
return Impl.isLegalMaskedLoad(DataType, Alignment);
}
bool isLegalNTStore(Type *DataType, Align Alignment) override {
@@ -1571,10 +1571,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
bool isLegalNTLoad(Type *DataType, Align Alignment) override {
return Impl.isLegalNTLoad(DataType, Alignment);
}
- bool isLegalMaskedScatter(Type *DataType, MaybeAlign Alignment) override {
+ bool isLegalMaskedScatter(Type *DataType, Align Alignment) override {
return Impl.isLegalMaskedScatter(DataType, Alignment);
}
- bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment) override {
+ bool isLegalMaskedGather(Type *DataType, Align Alignment) override {
return Impl.isLegalMaskedGather(DataType, Alignment);
}
bool isLegalMaskedCompressStore(Type *DataType) override {
@@ -1787,7 +1787,7 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) override {
return Impl.getVectorInstrCost(Opcode, Val, Index);
}
- int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
+ int getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind,
const Instruction *I) override {
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 669e4b4f3ff6..05c53197d6cc 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -180,11 +180,9 @@ class TargetTransformInfoImplBase {
bool shouldFavorBackedgeIndex(const Loop *L) const { return false; }
- bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) {
- return false;
- }
+ bool isLegalMaskedStore(Type *DataType, Align Alignment) { return false; }
- bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment) { return false; }
+ bool isLegalMaskedLoad(Type *DataType, Align Alignment) { return false; }
bool isLegalNTStore(Type *DataType, Align Alignment) {
// By default, assume nontemporal memory stores are available for stores
@@ -200,13 +198,9 @@ class TargetTransformInfoImplBase {
return Alignment >= DataSize && isPowerOf2_32(DataSize);
}
- bool isLegalMaskedScatter(Type *DataType, MaybeAlign Alignment) {
- return false;
- }
+ bool isLegalMaskedScatter(Type *DataType, Align Alignment) { return false; }
- bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment) {
- return false;
- }
+ bool isLegalMaskedGather(Type *DataType, Align Alignment) { return false; }
bool isLegalMaskedCompressStore(Type *DataType) { return false; }
@@ -441,7 +435,7 @@ class TargetTransformInfoImplBase {
return 1;
}
- unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
+ unsigned getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
unsigned AddressSpace, TTI::TargetCostKind CostKind,
const Instruction *I) const {
return 1;
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index cda3d16b9526..d919020f9ecd 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -285,12 +285,12 @@ bool TargetTransformInfo::shouldFavorBackedgeIndex(const Loop *L) const {
}
bool TargetTransformInfo::isLegalMaskedStore(Type *DataType,
- MaybeAlign Alignment) const {
+ Align Alignment) const {
return TTIImpl->isLegalMaskedStore(DataType, Alignment);
}
bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType,
- MaybeAlign Alignment) const {
+ Align Alignment) const {
return TTIImpl->isLegalMaskedLoad(DataType, Alignment);
}
@@ -304,12 +304,12 @@ bool TargetTransformInfo::isLegalNTLoad(Type *DataType, Align Alignment) const {
}
bool TargetTransformInfo::isLegalMaskedGather(Type *DataType,
- MaybeAlign Alignment) const {
+ Align Alignment) const {
return TTIImpl->isLegalMaskedGather(DataType, Alignment);
}
bool TargetTransformInfo::isLegalMaskedScatter(Type *DataType,
- MaybeAlign Alignment) const {
+ Align Alignment) const {
return TTIImpl->isLegalMaskedScatter(DataType, Alignment);
}
@@ -658,8 +658,7 @@ int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
}
int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
- MaybeAlign Alignment,
- unsigned AddressSpace,
+ Align Alignment, unsigned AddressSpace,
TTI::TargetCostKind CostKind,
const Instruction *I) const {
assert((I == nullptr || I->getOpcode() == Opcode) &&
@@ -1245,14 +1244,12 @@ int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const {
case Instruction::Store: {
const StoreInst *SI = cast<StoreInst>(I);
Type *ValTy = SI->getValueOperand()->getType();
- return getMemoryOpCost(I->getOpcode(), ValTy,
- MaybeAlign(SI->getAlignment()),
+ return getMemoryOpCost(I->getOpcode(), ValTy, SI->getAlign(),
SI->getPointerAddressSpace(), CostKind, I);
}
case Instruction::Load: {
const LoadInst *LI = cast<LoadInst>(I);
- return getMemoryOpCost(I->getOpcode(), I->getType(),
- MaybeAlign(LI->getAlignment()),
+ return getMemoryOpCost(I->getOpcode(), I->getType(), LI->getAlign(),
LI->getPointerAddressSpace(), CostKind, I);
}
case Instruction::ZExt:
diff --git a/llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp b/llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
index 4ad507c8e01c..d091f996df17 100644
--- a/llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
+++ b/llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
@@ -43,6 +43,7 @@ namespace {
class ScalarizeMaskedMemIntrin : public FunctionPass {
const TargetTransformInfo *TTI = nullptr;
+ const DataLayout *DL = nullptr;
public:
static char ID; // Pass identification, replacement for typeid
@@ -814,6 +815,7 @@ bool ScalarizeMaskedMemIntrin::runOnFunction(Function &F) {
bool EverMadeChange = false;
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
+ DL = &F.getParent()->getDataLayout();
bool MadeChange = true;
while (MadeChange) {
@@ -871,18 +873,23 @@ bool ScalarizeMaskedMemIntrin::optimizeCallInst(CallInst *CI,
scalarizeMaskedStore(CI, ModifiedDT);
return true;
case Intrinsic::masked_gather: {
- unsigned Alignment =
+ unsigned AlignmentInt =
cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
- if (TTI->isLegalMaskedGather(CI->getType(), MaybeAlign(Alignment)))
+ Type *LoadTy = CI->getType();
+ Align Alignment =
+ DL->getValueOrABITypeAlignment(MaybeAlign(AlignmentInt), LoadTy);
+ if (TTI->isLegalMaskedGather(LoadTy, Alignment))
return false;
scalarizeMaskedGather(CI, ModifiedDT);
return true;
}
case Intrinsic::masked_scatter: {
- unsigned Alignment =
+ unsigned AlignmentInt =
cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
- if (TTI->isLegalMaskedScatter(CI->getArgOperand(0)->getType(),
- MaybeAlign(Alignment)))
+ Type *StoreTy = CI->getArgOperand(0)->getType();
+ Align Alignment =
+ DL->getValueOrABITypeAlignment(MaybeAlign(AlignmentInt), StoreTy);
+ if (TTI->isLegalMaskedScatter(StoreTy, Alignment))
return false;
scalarizeMaskedScatter(CI, ModifiedDT);
return true;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 9c47e6267af7..9b03c064185d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1201,27 +1201,27 @@ class LoopVectorizationCostModel {
/// Returns true if the target machine supports masked store operation
/// for the given \p DataType and kind of access to \p Ptr.
- bool isLegalMaskedStore(Type *DataType, Value *Ptr, MaybeAlign Alignment) {
+ bool isLegalMaskedStore(Type *DataType, Value *Ptr, Align Alignment) {
return Legal->isConsecutivePtr(Ptr) &&
TTI.isLegalMaskedStore(DataType, Alignment);
}
/// Returns true if the target machine supports masked load operation
/// for the given \p DataType and kind of access to \p Ptr.
- bool isLegalMaskedLoad(Type *DataType, Value *Ptr, MaybeAlign Alignment) {
+ bool isLegalMaskedLoad(Type *DataType, Value *Ptr, Align Alignment) {
return Legal->isConsecutivePtr(Ptr) &&
TTI.isLegalMaskedLoad(DataType, Alignment);
}
/// Returns true if the target machine supports masked scatter operation
/// for the given \p DataType.
- bool isLegalMaskedScatter(Type *DataType, MaybeAlign Alignment) {
+ bool isLegalMaskedScatter(Type *DataType, Align Alignment) {
return TTI.isLegalMaskedScatter(DataType, Alignment);
}
/// Returns true if the target machine supports masked gather operation
/// for the given \p DataType.
- bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment) {
+ bool isLegalMaskedGather(Type *DataType, Align Alignment) {
return TTI.isLegalMaskedGather(DataType, Alignment);
}
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 2d0a95736e13..5b811082f8b9 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -3540,7 +3540,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
}
case Instruction::Load: {
// Cost of wide load - cost of scalar loads.
- MaybeAlign alignment(cast<LoadInst>(VL0)->getAlignment());
+ Align alignment = cast<LoadInst>(VL0)->getAlign();
int ScalarEltCost =
TTI->getMemoryOpCost(Instruction::Load, ScalarTy, alignment, 0,
CostKind, VL0);
@@ -3563,7 +3563,7 @@ int BoUpSLP::getEntryCost(TreeEntry *E) {
bool IsReorder = !E->ReorderIndices.empty();
auto *SI =
cast<StoreInst>(IsReorder ? VL[E->ReorderIndices.front()] : VL0);
- MaybeAlign Alignment(SI->getAlignment());
+ Align Alignment = SI->getAlign();
int ScalarEltCost =
TTI->getMemoryOpCost(Instruction::Store, ScalarTy, Alignment, 0,
CostKind, VL0);
More information about the llvm-commits
mailing list