Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,39 @@ InstructionCost ARMTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,

if (!Mask.empty()) {
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(SrcTy);
// Check for LD2/LD4 instructions, which are represented in llvm IR as
// deinterleaving-shuffle(load). The shuffle cost could potentially be
// free, but we model it with a cost of LT.first so that LD2/LD4 have a
// higher cost than just the load.
if (Args.size() >= 1 && isa<LoadInst>(Args[0]) &&
(LT.second.getScalarSizeInBits() == 8 ||
LT.second.getScalarSizeInBits() == 16 ||
LT.second.getScalarSizeInBits() == 32) &&
LT.second.getSizeInBits() == 128 &&
((TLI->getMaxSupportedInterleaveFactor() >= 2 &&
ShuffleVectorInst::isDeInterleaveMaskOfFactor(Mask, 2)) ||
(TLI->getMaxSupportedInterleaveFactor() == 4 &&
ShuffleVectorInst::isDeInterleaveMaskOfFactor(Mask, 4))))
return ST->getMVEVectorCostFactor(CostKind) *
std::max<InstructionCost>(1, LT.first / 4);

// Check for ST2/ST4 instructions, which are represented in llvm IR as
// store(interleaving-shuffle). The shuffle cost could potentially be
// free, but we model it with a cost of LT.first so that ST2/ST4 have a
// higher cost than just the store.
if (CxtI && CxtI->hasOneUse() && isa<StoreInst>(*CxtI->user_begin()) &&
(LT.second.getScalarSizeInBits() == 8 ||
LT.second.getScalarSizeInBits() == 16 ||
LT.second.getScalarSizeInBits() == 32) &&
LT.second.getSizeInBits() == 128 &&
((TLI->getMaxSupportedInterleaveFactor() >= 2 &&
ShuffleVectorInst::isInterleaveMask(
Mask, 2, SrcTy->getElementCount().getKnownMinValue() * 2)) ||
(TLI->getMaxSupportedInterleaveFactor() == 4 &&
ShuffleVectorInst::isInterleaveMask(
Mask, 4, SrcTy->getElementCount().getKnownMinValue() * 2))))
return ST->getMVEVectorCostFactor(CostKind) * LT.first;

if (LT.second.isVector() &&
Mask.size() <= LT.second.getVectorNumElements() &&
(isVREVMask(Mask, LT.second, 16) || isVREVMask(Mask, LT.second, 32) ||
Expand Down
Loading
Loading