-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ARM][MVE] Add shuffle costs for LDn and STn instructions. #145304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1336,6 +1336,37 @@ 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 && | ||
(ShuffleVectorInst::isDeInterleaveMaskOfFactor(Mask, 2) || | ||
(TLI->getMaxSupportedInterleaveFactor() == 4 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be >= 4, I think. |
||
ShuffleVectorInst::isDeInterleaveMaskOfFactor(Mask, 4)))) | ||
return ST->getMVEVectorCostFactor(TTI::TCK_RecipThroughput) * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be using the CostKind passed in as an argument? (Though I notice elsewhere in the function it's ignoring the argument and just using RecipThroughput) |
||
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 && | ||
(ShuffleVectorInst::isInterleaveMask( | ||
Mask, 2, SrcTy->getElementCount().getKnownMinValue() * 2) || | ||
(TLI->getMaxSupportedInterleaveFactor() == 4 && | ||
ShuffleVectorInst::isInterleaveMask( | ||
Mask, 4, SrcTy->getElementCount().getKnownMinValue() * 2)))) | ||
return ST->getMVEVectorCostFactor(TTI::TCK_RecipThroughput) * LT.first; | ||
|
||
if (LT.second.isVector() && | ||
Mask.size() <= LT.second.getVectorNumElements() && | ||
(isVREVMask(Mask, LT.second, 16) || isVREVMask(Mask, LT.second, 32) || | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check MaxSupportedInterleaveFactor() >= 2 here? (So -mve-max-interleave-factor=1 will work as expected)