Skip to content

Commit a4783ef

Browse files
committed
[Alignment][NFC] getMemoryOpCost uses MaybeAlign
Summary: 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 Reviewers: courbet Subscribers: nemanjai, hiraditya, kbarton, MaskRay, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69307
1 parent 3c7c371 commit a4783ef

18 files changed

+80
-66
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,9 @@ class TargetTransformInfo {
930930
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index = -1) const;
931931

932932
/// \return The cost of Load and Store instructions.
933-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
934-
unsigned AddressSpace, const Instruction *I = nullptr) const;
933+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
934+
unsigned AddressSpace,
935+
const Instruction *I = nullptr) const;
935936

936937
/// \return The cost of masked Load and Store instructions.
937938
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
@@ -1305,7 +1306,7 @@ class TargetTransformInfo::Concept {
13051306
Type *CondTy, const Instruction *I) = 0;
13061307
virtual int getVectorInstrCost(unsigned Opcode, Type *Val,
13071308
unsigned Index) = 0;
1308-
virtual int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
1309+
virtual int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
13091310
unsigned AddressSpace, const Instruction *I) = 0;
13101311
virtual int getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
13111312
unsigned Alignment,
@@ -1711,7 +1712,7 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
17111712
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) override {
17121713
return Impl.getVectorInstrCost(Opcode, Val, Index);
17131714
}
1714-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
1715+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
17151716
unsigned AddressSpace, const Instruction *I) override {
17161717
return Impl.getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
17171718
}

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class TargetTransformInfoImplBase {
447447
return 1;
448448
}
449449

450-
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
450+
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
451451
unsigned AddressSpace, const Instruction *I) {
452452
return 1;
453453
}

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
869869
return LT.first;
870870
}
871871

872-
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
873-
unsigned AddressSpace, const Instruction *I = nullptr) {
872+
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
873+
unsigned AddressSpace,
874+
const Instruction *I = nullptr) {
874875
assert(!Src->isVoidTy() && "Invalid type");
875876
std::pair<unsigned, MVT> LT = getTLI()->getTypeLegalizationCost(DL, Src);
876877

@@ -921,8 +922,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
921922
Cost = static_cast<T *>(this)->getMaskedMemoryOpCost(
922923
Opcode, VecTy, Alignment, AddressSpace);
923924
else
924-
Cost = static_cast<T *>(this)->getMemoryOpCost(Opcode, VecTy, Alignment,
925-
AddressSpace);
925+
Cost = static_cast<T *>(this)->getMemoryOpCost(
926+
Opcode, VecTy, MaybeAlign(Alignment), AddressSpace);
926927

927928
// Legalize the vector type, and get the legalized and unlegalized type
928929
// sizes.

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ int TargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
639639
}
640640

641641
int TargetTransformInfo::getMemoryOpCost(unsigned Opcode, Type *Src,
642-
unsigned Alignment,
642+
MaybeAlign Alignment,
643643
unsigned AddressSpace,
644644
const Instruction *I) const {
645645
assert ((I == nullptr || I->getOpcode() == Opcode) &&
@@ -1201,14 +1201,14 @@ int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const {
12011201
const StoreInst *SI = cast<StoreInst>(I);
12021202
Type *ValTy = SI->getValueOperand()->getType();
12031203
return getMemoryOpCost(I->getOpcode(), ValTy,
1204-
SI->getAlignment(),
1205-
SI->getPointerAddressSpace(), I);
1204+
MaybeAlign(SI->getAlignment()),
1205+
SI->getPointerAddressSpace(), I);
12061206
}
12071207
case Instruction::Load: {
12081208
const LoadInst *LI = cast<LoadInst>(I);
12091209
return getMemoryOpCost(I->getOpcode(), I->getType(),
1210-
LI->getAlignment(),
1211-
LI->getPointerAddressSpace(), I);
1210+
MaybeAlign(LI->getAlignment()),
1211+
LI->getPointerAddressSpace(), I);
12121212
}
12131213
case Instruction::ZExt:
12141214
case Instruction::SExt:

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,12 @@ AArch64TTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
632632
}
633633

634634
int AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
635-
unsigned Alignment, unsigned AddressSpace,
635+
MaybeAlign Alignment, unsigned AddressSpace,
636636
const Instruction *I) {
637637
auto LT = TLI->getTypeLegalizationCost(DL, Ty);
638638

639639
if (ST->isMisaligned128StoreSlow() && Opcode == Instruction::Store &&
640-
LT.second.is128BitVector() && Alignment < 16) {
640+
LT.second.is128BitVector() && (!Alignment || *Alignment < Align(16))) {
641641
// Unaligned stores are extremely inefficient. We don't split all
642642
// unaligned 128-bit stores because the negative impact that has shown in
643643
// practice on inlined block copy code.
@@ -703,8 +703,8 @@ int AArch64TTIImpl::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) {
703703
if (!I->isVectorTy())
704704
continue;
705705
if (I->getScalarSizeInBits() * I->getVectorNumElements() == 128)
706-
Cost += getMemoryOpCost(Instruction::Store, I, 128, 0) +
707-
getMemoryOpCost(Instruction::Load, I, 128, 0);
706+
Cost += getMemoryOpCost(Instruction::Store, I, Align(128), 0) +
707+
getMemoryOpCost(Instruction::Load, I, Align(128), 0);
708708
}
709709
return Cost;
710710
}

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
134134
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize,
135135
bool IsZeroCmp) const;
136136

137-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
137+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
138138
unsigned AddressSpace, const Instruction *I = nullptr);
139139

140140
int getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys);

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,13 @@ int ARMTTIImpl::getArithmeticInstrCost(
735735
return BaseCost;
736736
}
737737

738-
int ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
739-
unsigned AddressSpace, const Instruction *I) {
738+
int ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
739+
MaybeAlign Alignment, unsigned AddressSpace,
740+
const Instruction *I) {
740741
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Src);
741742

742-
if (ST->hasNEON() && Src->isVectorTy() && Alignment != 16 &&
743+
if (ST->hasNEON() && Src->isVectorTy() &&
744+
(Alignment && *Alignment != Align(16)) &&
743745
Src->getVectorElementType()->isDoubleTy()) {
744746
// Unaligned loads/stores are extremely inefficient.
745747
// We need 4 uops for vst.1/vld.1 vs 1uop for vldr/vstr.

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
189189
TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
190190
ArrayRef<const Value *> Args = ArrayRef<const Value *>());
191191

192-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
192+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
193193
unsigned AddressSpace, const Instruction *I = nullptr);
194194

195195
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ unsigned HexagonTTIImpl::getAddressComputationCost(Type *Tp,
152152
}
153153

154154
unsigned HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
155-
unsigned Alignment, unsigned AddressSpace, const Instruction *I) {
155+
MaybeAlign Alignment,
156+
unsigned AddressSpace,
157+
const Instruction *I) {
156158
assert(Opcode == Instruction::Load || Opcode == Instruction::Store);
157159
if (Opcode == Instruction::Store)
158160
return BaseT::getMemoryOpCost(Opcode, Src, Alignment, AddressSpace, I);
@@ -166,24 +168,30 @@ unsigned HexagonTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
166168
// Cost of HVX loads.
167169
if (VecWidth % RegWidth == 0)
168170
return VecWidth / RegWidth;
169-
// Cost of constructing HVX vector from scalar loads.
170-
Alignment = std::min(Alignment, RegWidth / 8);
171-
unsigned AlignWidth = 8 * std::max(1u, Alignment);
171+
// Cost of constructing HVX vector from scalar loads
172+
const Align RegAlign(RegWidth / 8);
173+
if (!Alignment || *Alignment > RegAlign)
174+
Alignment = RegAlign;
175+
assert(Alignment);
176+
unsigned AlignWidth = 8 * Alignment->value();
172177
unsigned NumLoads = alignTo(VecWidth, AlignWidth) / AlignWidth;
173178
return 3 * NumLoads;
174179
}
175180

176181
// Non-HVX vectors.
177182
// Add extra cost for floating point types.
178-
unsigned Cost = VecTy->getElementType()->isFloatingPointTy() ? FloatFactor
179-
: 1;
180-
Alignment = std::min(Alignment, 8u);
181-
unsigned AlignWidth = 8 * std::max(1u, Alignment);
183+
unsigned Cost =
184+
VecTy->getElementType()->isFloatingPointTy() ? FloatFactor : 1;
185+
186+
// At this point unspecified alignment is considered as Align::None().
187+
const Align BoundAlignment = std::min(Alignment.valueOrOne(), Align(8));
188+
unsigned AlignWidth = 8 * BoundAlignment.value();
182189
unsigned NumLoads = alignTo(VecWidth, AlignWidth) / AlignWidth;
183-
if (Alignment == 4 || Alignment == 8)
190+
if (Alignment == Align(4) || Alignment == Align(8))
184191
return Cost * NumLoads;
185192
// Loads of less than 32 bits will need extra inserts to compose a vector.
186-
unsigned LogA = Log2_32(Alignment);
193+
assert(BoundAlignment <= Align(8));
194+
unsigned LogA = Log2(BoundAlignment);
187195
return (3 - LogA) * Cost * NumLoads;
188196
}
189197

@@ -214,7 +222,8 @@ unsigned HexagonTTIImpl::getInterleavedMemoryOpCost(unsigned Opcode,
214222
return BaseT::getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
215223
Alignment, AddressSpace,
216224
UseMaskForCond, UseMaskForGaps);
217-
return getMemoryOpCost(Opcode, VecTy, Alignment, AddressSpace, nullptr);
225+
return getMemoryOpCost(Opcode, VecTy, MaybeAlign(Alignment), AddressSpace,
226+
nullptr);
218227
}
219228

220229
unsigned HexagonTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
112112
unsigned ScalarizationCostPassed = UINT_MAX);
113113
unsigned getAddressComputationCost(Type *Tp, ScalarEvolution *SE,
114114
const SCEV *S);
115-
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
116-
unsigned AddressSpace, const Instruction *I = nullptr);
115+
unsigned getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
116+
unsigned AddressSpace,
117+
const Instruction *I = nullptr);
117118
unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
118119
unsigned AddressSpace);
119120
unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,9 @@ int PPCTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
829829
return Cost;
830830
}
831831

832-
int PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
833-
unsigned AddressSpace, const Instruction *I) {
832+
int PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
833+
MaybeAlign Alignment, unsigned AddressSpace,
834+
const Instruction *I) {
834835
// Legalize the type.
835836
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Src);
836837
assert((Opcode == Instruction::Load || Opcode == Instruction::Store) &&
@@ -888,7 +889,8 @@ int PPCTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
888889
// to be decomposed based on the alignment factor.
889890

890891
// Add the cost of each scalar load or store.
891-
Cost += LT.first*(SrcBytes/Alignment-1);
892+
assert(Alignment);
893+
Cost += LT.first * ((SrcBytes / Alignment->value()) - 1);
892894

893895
// For a vector type, there is also scalarization overhead (only for
894896
// stores, loads are expanded using the vector-load + permutation sequence,
@@ -919,7 +921,8 @@ int PPCTTIImpl::getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
919921
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, VecTy);
920922

921923
// Firstly, the cost of load/store operation.
922-
int Cost = getMemoryOpCost(Opcode, VecTy, Alignment, AddressSpace);
924+
int Cost =
925+
getMemoryOpCost(Opcode, VecTy, MaybeAlign(Alignment), AddressSpace);
923926

924927
// PPC, for both Altivec/VSX and QPX, support cheap arbitrary permutations
925928
// (at least in the sense that there need only be one non-loop-invariant

llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class PPCTTIImpl : public BasicTTIImplBase<PPCTTIImpl> {
9797
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
9898
const Instruction *I = nullptr);
9999
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
100-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
100+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
101101
unsigned AddressSpace, const Instruction *I = nullptr);
102102
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
103103
unsigned Factor,

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ void SystemZTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
259259
}
260260
if (isa<StoreInst>(&I)) {
261261
Type *MemAccessTy = I.getOperand(0)->getType();
262-
NumStores += getMemoryOpCost(Instruction::Store, MemAccessTy, 0, 0);
262+
NumStores += getMemoryOpCost(Instruction::Store, MemAccessTy, None, 0);
263263
}
264264
}
265265

@@ -995,7 +995,7 @@ static bool isBswapIntrinsicCall(const Value *V) {
995995
}
996996

997997
int SystemZTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
998-
unsigned Alignment, unsigned AddressSpace,
998+
MaybeAlign Alignment, unsigned AddressSpace,
999999
const Instruction *I) {
10001000
assert(!Src->isVoidTy() && "Invalid type");
10011001

llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
8787
const Instruction *I = nullptr);
8888
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
8989
bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
90-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
90+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
9191
unsigned AddressSpace, const Instruction *I = nullptr);
9292

9393
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,

llvm/lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,8 +2404,9 @@ int X86TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
24042404
return BaseT::getVectorInstrCost(Opcode, Val, Index) + RegisterFileMoveCost;
24052405
}
24062406

2407-
int X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
2408-
unsigned AddressSpace, const Instruction *I) {
2407+
int X86TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
2408+
MaybeAlign Alignment, unsigned AddressSpace,
2409+
const Instruction *I) {
24092410
// Handle non-power-of-two vectors such as <3 x float>
24102411
if (VectorType *VTy = dyn_cast<VectorType>(Src)) {
24112412
unsigned NumElem = VTy->getVectorNumElements();
@@ -2456,7 +2457,7 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
24562457
VectorType *SrcVTy = dyn_cast<VectorType>(SrcTy);
24572458
if (!SrcVTy)
24582459
// To calculate scalar take the regular cost, without mask
2459-
return getMemoryOpCost(Opcode, SrcTy, Alignment, AddressSpace);
2460+
return getMemoryOpCost(Opcode, SrcTy, MaybeAlign(Alignment), AddressSpace);
24602461

24612462
unsigned NumElem = SrcVTy->getVectorNumElements();
24622463
VectorType *MaskTy =
@@ -2474,7 +2475,7 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
24742475
int ValueSplitCost = getScalarizationOverhead(SrcVTy, IsLoad, IsStore);
24752476
int MemopCost =
24762477
NumElem * BaseT::getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
2477-
Alignment, AddressSpace);
2478+
MaybeAlign(Alignment), AddressSpace);
24782479
return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost;
24792480
}
24802481

@@ -3164,7 +3165,7 @@ int X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy, Value *Ptr,
31643165
? ST->getGatherOverhead()
31653166
: ST->getScatterOverhead();
31663167
return GSOverhead + VF * getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
3167-
Alignment, AddressSpace);
3168+
MaybeAlign(Alignment), AddressSpace);
31683169
}
31693170

31703171
/// Return the cost of full scalarization of gather / scatter operation.
@@ -3194,7 +3195,7 @@ int X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy,
31943195

31953196
// The cost of the scalar loads/stores.
31963197
int MemoryOpCost = VF * getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
3197-
Alignment, AddressSpace);
3198+
MaybeAlign(Alignment), AddressSpace);
31983199

31993200
int InsertExtractCost = 0;
32003201
if (Opcode == Instruction::Load)
@@ -3520,8 +3521,8 @@ int X86TTIImpl::getInterleavedMemoryOpCostAVX2(unsigned Opcode, Type *VecTy,
35203521
// Get the cost of one memory operation.
35213522
Type *SingleMemOpTy = VectorType::get(VecTy->getVectorElementType(),
35223523
LegalVT.getVectorNumElements());
3523-
unsigned MemOpCost =
3524-
getMemoryOpCost(Opcode, SingleMemOpTy, Alignment, AddressSpace);
3524+
unsigned MemOpCost = getMemoryOpCost(Opcode, SingleMemOpTy,
3525+
MaybeAlign(Alignment), AddressSpace);
35253526

35263527
VectorType *VT = VectorType::get(ScalarTy, VF);
35273528
EVT ETy = TLI->getValueType(DL, VT);
@@ -3620,8 +3621,8 @@ int X86TTIImpl::getInterleavedMemoryOpCostAVX512(unsigned Opcode, Type *VecTy,
36203621
// Get the cost of one memory operation.
36213622
Type *SingleMemOpTy = VectorType::get(VecTy->getVectorElementType(),
36223623
LegalVT.getVectorNumElements());
3623-
unsigned MemOpCost =
3624-
getMemoryOpCost(Opcode, SingleMemOpTy, Alignment, AddressSpace);
3624+
unsigned MemOpCost = getMemoryOpCost(Opcode, SingleMemOpTy,
3625+
MaybeAlign(Alignment), AddressSpace);
36253626

36263627
unsigned VF = VecTy->getVectorNumElements() / Factor;
36273628
MVT VT = MVT::getVectorVT(MVT::getVT(VecTy->getScalarType()), VF);

llvm/lib/Target/X86/X86TargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
133133
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
134134
const Instruction *I = nullptr);
135135
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
136-
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
136+
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
137137
unsigned AddressSpace, const Instruction *I = nullptr);
138138
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
139139
unsigned AddressSpace);

0 commit comments

Comments
 (0)