[llvm] 9328cc0 - [VectorCombine] Add explicit CostKind to all getShuffleCost calls. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 9 05:06:24 PST 2024
Author: Simon Pilgrim
Date: 2024-12-09T13:01:14Z
New Revision: 9328cc0f6717199d116f149048c9d2ee3c1902c0
URL: https://github.com/llvm/llvm-project/commit/9328cc0f6717199d116f149048c9d2ee3c1902c0
DIFF: https://github.com/llvm/llvm-project/commit/9328cc0f6717199d116f149048c9d2ee3c1902c0.diff
LOG: [VectorCombine] Add explicit CostKind to all getShuffleCost calls. NFC.
We currently hardwire CostKind to TTI::TCK_RecipThroughput which matches the default CostKind for getShuffleCost.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 9635b106c6158b..b0dd3d5a4fbaa2 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -271,7 +271,8 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
assert(OffsetEltIndex < MinVecNumElts && "Address offset too big");
Mask[0] = OffsetEltIndex;
if (OffsetEltIndex)
- NewCost += TTI.getShuffleCost(TTI::SK_PermuteSingleSrc, MinVecTy, Mask);
+ NewCost +=
+ TTI.getShuffleCost(TTI::SK_PermuteSingleSrc, MinVecTy, Mask, CostKind);
// We can aggressively convert to the vector form because the backend can
// invert this transform if it does not result in a performance win.
@@ -694,7 +695,7 @@ bool VectorCombine::foldInsExtFNeg(Instruction &I) {
InstructionCost NewCost =
TTI.getArithmeticInstrCost(Instruction::FNeg, VecTy) +
- TTI.getShuffleCost(TargetTransformInfo::SK_Select, VecTy, Mask);
+ TTI.getShuffleCost(TargetTransformInfo::SK_Select, VecTy, Mask, CostKind);
if (NewCost > OldCost)
return false;
@@ -843,7 +844,8 @@ bool VectorCombine::scalarizeVPIntrinsic(Instruction &I) {
Mask.resize(FVTy->getNumElements(), 0);
InstructionCost SplatCost =
TTI.getVectorInstrCost(Instruction::InsertElement, VecTy, CostKind, 0) +
- TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy, Mask);
+ TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy, Mask,
+ CostKind);
// Calculate the cost of the VP Intrinsic
SmallVector<Type *, 4> Args;
@@ -1112,7 +1114,7 @@ bool VectorCombine::foldExtractedCmps(Instruction &I) {
SmallVector<int, 32> ShufMask(VecTy->getNumElements(), PoisonMaskElem);
ShufMask[CheapIndex] = ExpensiveIndex;
NewCost += TTI.getShuffleCost(TargetTransformInfo::SK_PermuteSingleSrc, CmpTy,
- ShufMask);
+ ShufMask, CostKind);
NewCost += TTI.getArithmeticInstrCost(I.getOpcode(), CmpTy);
NewCost += TTI.getVectorInstrCost(*Ext0, CmpTy, CostKind, CheapIndex);
NewCost += Ext0->hasOneUse() ? 0 : Ext0Cost;
@@ -2288,10 +2290,10 @@ bool VectorCombine::foldShuffleFromReductions(Instruction &I) {
(UsesSecondVec && !IsTruncatingShuffle) ? VecType : ShuffleInputType;
InstructionCost OldCost = TTI.getShuffleCost(
UsesSecondVec ? TTI::SK_PermuteTwoSrc : TTI::SK_PermuteSingleSrc,
- VecTyForCost, Shuffle->getShuffleMask());
+ VecTyForCost, Shuffle->getShuffleMask(), CostKind);
InstructionCost NewCost = TTI.getShuffleCost(
UsesSecondVec ? TTI::SK_PermuteTwoSrc : TTI::SK_PermuteSingleSrc,
- VecTyForCost, ConcatMask);
+ VecTyForCost, ConcatMask, CostKind);
LLVM_DEBUG(dbgs() << "Found a reduction feeding from a shuffle: " << *Shuffle
<< "\n");
@@ -2605,10 +2607,10 @@ bool VectorCombine::foldSelectShuffle(Instruction &I, bool FromReduction) {
return C + TTI.getShuffleCost(isa<UndefValue>(SV->getOperand(1))
? TTI::SK_PermuteSingleSrc
: TTI::SK_PermuteTwoSrc,
- VT, SV->getShuffleMask());
+ VT, SV->getShuffleMask(), CostKind);
};
auto AddShuffleMaskCost = [&](InstructionCost C, ArrayRef<int> Mask) {
- return C + TTI.getShuffleCost(TTI::SK_PermuteTwoSrc, VT, Mask);
+ return C + TTI.getShuffleCost(TTI::SK_PermuteTwoSrc, VT, Mask, CostKind);
};
// Get the costs of the shuffles + binops before and after with the new
@@ -2817,8 +2819,8 @@ bool VectorCombine::foldInsExtVectorToShuffle(Instruction &I) {
TTI.getVectorInstrCost(*Ext, VecTy, CostKind, ExtIdx) +
TTI.getVectorInstrCost(*Ins, VecTy, CostKind, InsIdx);
- InstructionCost NewCost =
- TTI.getShuffleCost(TargetTransformInfo::SK_PermuteTwoSrc, VecTy, Mask);
+ InstructionCost NewCost = TTI.getShuffleCost(
+ TargetTransformInfo::SK_PermuteTwoSrc, VecTy, Mask, CostKind);
if (!Ext->hasOneUse())
NewCost += TTI.getVectorInstrCost(*Ext, VecTy, CostKind, ExtIdx);
More information about the llvm-commits
mailing list