Skip to content

Commit a482337

Browse files
committed
[ARM] Add basic masked load/store costs
This adds some basic MVE masked load/store costs, notably changing the cost of legal loads/stores to the MVECostFactor and the cost of scalarized instructions to 8*NumElts. Differential Revision: https://reviews.llvm.org/D86538
1 parent ab97c9b commit a482337

File tree

3 files changed

+418
-396
lines changed

3 files changed

+418
-396
lines changed

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,24 @@ int ARMTTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src,
13181318
CostKind, I);
13191319
}
13201320

1321+
unsigned ARMTTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *Src,
1322+
Align Alignment,
1323+
unsigned AddressSpace,
1324+
TTI::TargetCostKind CostKind) {
1325+
if (ST->hasMVEIntegerOps()) {
1326+
if (Opcode == Instruction::Load && isLegalMaskedLoad(Src, Alignment))
1327+
return ST->getMVEVectorCostFactor();
1328+
if (Opcode == Instruction::Store && isLegalMaskedStore(Src, Alignment))
1329+
return ST->getMVEVectorCostFactor();
1330+
}
1331+
if (!isa<FixedVectorType>(Src))
1332+
return BaseT::getMaskedMemoryOpCost(Opcode, Src, Alignment, AddressSpace,
1333+
CostKind);
1334+
// Scalar cost, which is currently very high due to the efficiency of the
1335+
// generated code.
1336+
return cast<FixedVectorType>(Src)->getNumElements() * 8;
1337+
}
1338+
13211339
int ARMTTIImpl::getInterleavedMemoryOpCost(
13221340
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
13231341
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
229229
TTI::TargetCostKind CostKind,
230230
const Instruction *I = nullptr);
231231

232+
unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
233+
unsigned AddressSpace,
234+
TTI::TargetCostKind CostKind);
235+
232236
int getInterleavedMemoryOpCost(
233237
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
234238
Align Alignment, unsigned AddressSpace,

0 commit comments

Comments
 (0)