Skip to content

Commit 554859c

Browse files
authored
[TTI] Make isLegalMasked{Load,Store} take an address space (#134006)
In order to facilitate targets that only support masked loads/stores on certain address spaces (AMDGPU will support them in an upcoming patch, but only for address space 7), add an AddressSpace parameter to isLegalMaskedLoad and isLegalMaskedStore
1 parent bb8a7a7 commit 554859c

14 files changed

+82
-48
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,11 @@ class TargetTransformInfo {
791791
ScalarEvolution *SE) const;
792792

793793
/// Return true if the target supports masked store.
794-
bool isLegalMaskedStore(Type *DataType, Align Alignment) const;
794+
bool isLegalMaskedStore(Type *DataType, Align Alignment,
795+
unsigned AddressSpace) const;
795796
/// Return true if the target supports masked load.
796-
bool isLegalMaskedLoad(Type *DataType, Align Alignment) const;
797+
bool isLegalMaskedLoad(Type *DataType, Align Alignment,
798+
unsigned AddressSpace) const;
797799

798800
/// Return true if the target supports nontemporal store.
799801
bool isLegalNTStore(Type *DataType, Align Alignment) const;
@@ -2015,8 +2017,10 @@ class TargetTransformInfo::Concept {
20152017
TargetLibraryInfo *LibInfo) = 0;
20162018
virtual AddressingModeKind
20172019
getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const = 0;
2018-
virtual bool isLegalMaskedStore(Type *DataType, Align Alignment) = 0;
2019-
virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment) = 0;
2020+
virtual bool isLegalMaskedStore(Type *DataType, Align Alignment,
2021+
unsigned AddressSpace) = 0;
2022+
virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment,
2023+
unsigned AddressSpace) = 0;
20202024
virtual bool isLegalNTStore(Type *DataType, Align Alignment) = 0;
20212025
virtual bool isLegalNTLoad(Type *DataType, Align Alignment) = 0;
20222026
virtual bool isLegalBroadcastLoad(Type *ElementTy,
@@ -2562,11 +2566,13 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
25622566
ScalarEvolution *SE) const override {
25632567
return Impl.getPreferredAddressingMode(L, SE);
25642568
}
2565-
bool isLegalMaskedStore(Type *DataType, Align Alignment) override {
2566-
return Impl.isLegalMaskedStore(DataType, Alignment);
2569+
bool isLegalMaskedStore(Type *DataType, Align Alignment,
2570+
unsigned AddressSpace) override {
2571+
return Impl.isLegalMaskedStore(DataType, Alignment, AddressSpace);
25672572
}
2568-
bool isLegalMaskedLoad(Type *DataType, Align Alignment) override {
2569-
return Impl.isLegalMaskedLoad(DataType, Alignment);
2573+
bool isLegalMaskedLoad(Type *DataType, Align Alignment,
2574+
unsigned AddressSpace) override {
2575+
return Impl.isLegalMaskedLoad(DataType, Alignment, AddressSpace);
25702576
}
25712577
bool isLegalNTStore(Type *DataType, Align Alignment) override {
25722578
return Impl.isLegalNTStore(DataType, Alignment);

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,13 @@ class TargetTransformInfoImplBase {
276276
return TTI::AMK_None;
277277
}
278278

279-
bool isLegalMaskedStore(Type *DataType, Align Alignment) const {
279+
bool isLegalMaskedStore(Type *DataType, Align Alignment,
280+
unsigned AddressSpace) const {
280281
return false;
281282
}
282283

283-
bool isLegalMaskedLoad(Type *DataType, Align Alignment) const {
284+
bool isLegalMaskedLoad(Type *DataType, Align Alignment,
285+
unsigned AddressSpace) const {
284286
return false;
285287
}
286288

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,14 @@ TargetTransformInfo::getPreferredAddressingMode(const Loop *L,
462462
return TTIImpl->getPreferredAddressingMode(L, SE);
463463
}
464464

465-
bool TargetTransformInfo::isLegalMaskedStore(Type *DataType,
466-
Align Alignment) const {
467-
return TTIImpl->isLegalMaskedStore(DataType, Alignment);
465+
bool TargetTransformInfo::isLegalMaskedStore(Type *DataType, Align Alignment,
466+
unsigned AddressSpace) const {
467+
return TTIImpl->isLegalMaskedStore(DataType, Alignment, AddressSpace);
468468
}
469469

470-
bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType,
471-
Align Alignment) const {
472-
return TTIImpl->isLegalMaskedLoad(DataType, Alignment);
470+
bool TargetTransformInfo::isLegalMaskedLoad(Type *DataType, Align Alignment,
471+
unsigned AddressSpace) const {
472+
return TTIImpl->isLegalMaskedLoad(DataType, Alignment, AddressSpace);
473473
}
474474

475475
bool TargetTransformInfo::isLegalNTStore(Type *DataType,

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,13 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
290290
return isElementTypeLegalForScalableVector(DataType->getScalarType());
291291
}
292292

293-
bool isLegalMaskedLoad(Type *DataType, Align Alignment) {
293+
bool isLegalMaskedLoad(Type *DataType, Align Alignment,
294+
unsigned /*AddressSpace*/) {
294295
return isLegalMaskedLoadStore(DataType, Alignment);
295296
}
296297

297-
bool isLegalMaskedStore(Type *DataType, Align Alignment) {
298+
bool isLegalMaskedStore(Type *DataType, Align Alignment,
299+
unsigned /*AddressSpace*/) {
298300
return isLegalMaskedLoadStore(DataType, Alignment);
299301
}
300302

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,8 @@ bool ARMTTIImpl::isProfitableLSRChainElement(Instruction *I) {
11221122
return false;
11231123
}
11241124

1125-
bool ARMTTIImpl::isLegalMaskedLoad(Type *DataTy, Align Alignment) {
1125+
bool ARMTTIImpl::isLegalMaskedLoad(Type *DataTy, Align Alignment,
1126+
unsigned /*AddressSpace*/) {
11261127
if (!EnableMaskedLoadStores || !ST->hasMVEIntegerOps())
11271128
return false;
11281129

@@ -1595,9 +1596,11 @@ ARMTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
15951596
unsigned AddressSpace,
15961597
TTI::TargetCostKind CostKind) {
15971598
if (ST->hasMVEIntegerOps()) {
1598-
if (Opcode == Instruction::Load && isLegalMaskedLoad(Src, Alignment))
1599+
if (Opcode == Instruction::Load &&
1600+
isLegalMaskedLoad(Src, Alignment, AddressSpace))
15991601
return ST->getMVEVectorCostFactor(CostKind);
1600-
if (Opcode == Instruction::Store && isLegalMaskedStore(Src, Alignment))
1602+
if (Opcode == Instruction::Store &&
1603+
isLegalMaskedStore(Src, Alignment, AddressSpace))
16011604
return ST->getMVEVectorCostFactor(CostKind);
16021605
}
16031606
if (!isa<FixedVectorType>(Src))

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,11 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
184184

185185
bool isProfitableLSRChainElement(Instruction *I);
186186

187-
bool isLegalMaskedLoad(Type *DataTy, Align Alignment);
187+
bool isLegalMaskedLoad(Type *DataTy, Align Alignment, unsigned AddressSpace);
188188

189-
bool isLegalMaskedStore(Type *DataTy, Align Alignment) {
190-
return isLegalMaskedLoad(DataTy, Alignment);
189+
bool isLegalMaskedStore(Type *DataTy, Align Alignment,
190+
unsigned AddressSpace) {
191+
return isLegalMaskedLoad(DataTy, Alignment, AddressSpace);
191192
}
192193

193194
bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment) {

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,15 @@ InstructionCost HexagonTTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
340340
return 1;
341341
}
342342

343-
bool HexagonTTIImpl::isLegalMaskedStore(Type *DataType, Align /*Alignment*/) {
343+
bool HexagonTTIImpl::isLegalMaskedStore(Type *DataType, Align /*Alignment*/,
344+
unsigned /*AddressSpace*/) {
344345
// This function is called from scalarize-masked-mem-intrin, which runs
345346
// in pre-isel. Use ST directly instead of calling isHVXVectorType.
346347
return HexagonMaskedVMem && ST.isTypeForHVX(DataType);
347348
}
348349

349-
bool HexagonTTIImpl::isLegalMaskedLoad(Type *DataType, Align /*Alignment*/) {
350+
bool HexagonTTIImpl::isLegalMaskedLoad(Type *DataType, Align /*Alignment*/,
351+
unsigned /*AddressSpace*/) {
350352
// This function is called from scalarize-masked-mem-intrin, which runs
351353
// in pre-isel. Use ST directly instead of calling isHVXVectorType.
352354
return HexagonMaskedVMem && ST.isTypeForHVX(DataType);

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
157157
return 1;
158158
}
159159

160-
bool isLegalMaskedStore(Type *DataType, Align Alignment);
161-
bool isLegalMaskedLoad(Type *DataType, Align Alignment);
160+
bool isLegalMaskedStore(Type *DataType, Align Alignment,
161+
unsigned AddressSpace);
162+
bool isLegalMaskedLoad(Type *DataType, Align Alignment,
163+
unsigned AddressSpace);
162164

163165
/// @}
164166

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,12 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
262262
return TLI->isLegalElementTypeForRVV(ElemType);
263263
}
264264

265-
bool isLegalMaskedLoad(Type *DataType, Align Alignment) {
265+
bool isLegalMaskedLoad(Type *DataType, Align Alignment,
266+
unsigned /*AddressSpace*/) {
266267
return isLegalMaskedLoadStore(DataType, Alignment);
267268
}
268-
bool isLegalMaskedStore(Type *DataType, Align Alignment) {
269+
bool isLegalMaskedStore(Type *DataType, Align Alignment,
270+
unsigned /*AddressSpace*/) {
269271
return isLegalMaskedLoadStore(DataType, Alignment);
270272
}
271273

llvm/lib/Target/VE/VETargetTransformInfo.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ class VETTIImpl : public BasicTTIImplBase<VETTIImpl> {
133133
}
134134

135135
// Load & Store {
136-
bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment) {
136+
bool isLegalMaskedLoad(Type *DataType, MaybeAlign Alignment,
137+
unsigned /*AddressSpace*/) {
137138
return isVectorLaneType(*getLaneType(DataType));
138139
}
139-
bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment) {
140+
bool isLegalMaskedStore(Type *DataType, MaybeAlign Alignment,
141+
unsigned /*AddressSpace*/) {
140142
return isVectorLaneType(*getLaneType(DataType));
141143
}
142144
bool isLegalMaskedGather(Type *DataType, MaybeAlign Alignment) {

0 commit comments

Comments
 (0)