[llvm] 3711329 - [TTI] getInstructionCost - pull out repeated getShuffleMask() calls. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 07:47:46 PST 2024
Author: Simon Pilgrim
Date: 2024-03-06T15:47:35Z
New Revision: 371132962b3566659d533bfe99c3e3cfb0dd37bd
URL: https://github.com/llvm/llvm-project/commit/371132962b3566659d533bfe99c3e3cfb0dd37bd
DIFF: https://github.com/llvm/llvm-project/commit/371132962b3566659d533bfe99c3e3cfb0dd37bd.diff
LOG: [TTI] getInstructionCost - pull out repeated getShuffleMask() calls. NFC.
Pulled out of #84156
Added:
Modified:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 95fb13d1c97154..71573b6b3b8f77 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -1324,6 +1324,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
auto *VecTy = cast<VectorType>(U->getType());
auto *VecSrcTy = cast<VectorType>(Operands[0]->getType());
+ ArrayRef<int> Mask = Shuffle->getShuffleMask();
int NumSubElts, SubIndex;
if (Shuffle->changesLength()) {
@@ -1333,21 +1334,19 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
if (Shuffle->isExtractSubvectorMask(SubIndex))
return TargetTTI->getShuffleCost(TTI::SK_ExtractSubvector, VecSrcTy,
- Shuffle->getShuffleMask(), CostKind,
- SubIndex, VecTy, Operands);
+ Mask, CostKind, SubIndex, VecTy,
+ Operands);
if (Shuffle->isInsertSubvectorMask(NumSubElts, SubIndex))
return TargetTTI->getShuffleCost(
- TTI::SK_InsertSubvector, VecTy, Shuffle->getShuffleMask(),
- CostKind, SubIndex,
+ TTI::SK_InsertSubvector, VecTy, Mask, CostKind, SubIndex,
FixedVectorType::get(VecTy->getScalarType(), NumSubElts),
Operands);
int ReplicationFactor, VF;
if (Shuffle->isReplicationMask(ReplicationFactor, VF)) {
- APInt DemandedDstElts =
- APInt::getZero(Shuffle->getShuffleMask().size());
- for (auto I : enumerate(Shuffle->getShuffleMask())) {
+ APInt DemandedDstElts = APInt::getZero(Mask.size());
+ for (auto I : enumerate(Mask)) {
if (I.value() != PoisonMaskElem)
DemandedDstElts.setBit(I.index());
}
@@ -1363,44 +1362,36 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
return 0;
if (Shuffle->isReverse())
- return TargetTTI->getShuffleCost(TTI::SK_Reverse, VecTy,
- Shuffle->getShuffleMask(), CostKind, 0,
- nullptr, Operands);
+ return TargetTTI->getShuffleCost(TTI::SK_Reverse, VecTy, Mask, CostKind,
+ 0, nullptr, Operands);
if (Shuffle->isSelect())
- return TargetTTI->getShuffleCost(TTI::SK_Select, VecTy,
- Shuffle->getShuffleMask(), CostKind, 0,
- nullptr, Operands);
+ return TargetTTI->getShuffleCost(TTI::SK_Select, VecTy, Mask, CostKind,
+ 0, nullptr, Operands);
if (Shuffle->isTranspose())
- return TargetTTI->getShuffleCost(TTI::SK_Transpose, VecTy,
- Shuffle->getShuffleMask(), CostKind, 0,
- nullptr, Operands);
+ return TargetTTI->getShuffleCost(TTI::SK_Transpose, VecTy, Mask,
+ CostKind, 0, nullptr, Operands);
if (Shuffle->isZeroEltSplat())
- return TargetTTI->getShuffleCost(TTI::SK_Broadcast, VecTy,
- Shuffle->getShuffleMask(), CostKind, 0,
- nullptr, Operands);
+ return TargetTTI->getShuffleCost(TTI::SK_Broadcast, VecTy, Mask,
+ CostKind, 0, nullptr, Operands);
if (Shuffle->isSingleSource())
- return TargetTTI->getShuffleCost(TTI::SK_PermuteSingleSrc, VecTy,
- Shuffle->getShuffleMask(), CostKind, 0,
- nullptr, Operands);
+ return TargetTTI->getShuffleCost(TTI::SK_PermuteSingleSrc, VecTy, Mask,
+ CostKind, 0, nullptr, Operands);
if (Shuffle->isInsertSubvectorMask(NumSubElts, SubIndex))
return TargetTTI->getShuffleCost(
- TTI::SK_InsertSubvector, VecTy, Shuffle->getShuffleMask(), CostKind,
- SubIndex, FixedVectorType::get(VecTy->getScalarType(), NumSubElts),
- Operands);
+ TTI::SK_InsertSubvector, VecTy, Mask, CostKind, SubIndex,
+ FixedVectorType::get(VecTy->getScalarType(), NumSubElts), Operands);
if (Shuffle->isSplice(SubIndex))
- return TargetTTI->getShuffleCost(TTI::SK_Splice, VecTy,
- Shuffle->getShuffleMask(), CostKind,
+ return TargetTTI->getShuffleCost(TTI::SK_Splice, VecTy, Mask, CostKind,
SubIndex, nullptr, Operands);
- return TargetTTI->getShuffleCost(TTI::SK_PermuteTwoSrc, VecTy,
- Shuffle->getShuffleMask(), CostKind, 0,
- nullptr, Operands);
+ return TargetTTI->getShuffleCost(TTI::SK_PermuteTwoSrc, VecTy, Mask,
+ CostKind, 0, nullptr, Operands);
}
case Instruction::ExtractElement: {
auto *EEI = dyn_cast<ExtractElementInst>(U);
More information about the llvm-commits
mailing list