[llvm] [VectorCombine] Add a mask for SK_Broadcast shuffle costing (PR #85808)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 08:53:38 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Philip Reames (preames)
<details>
<summary>Changes</summary>
This is part of a series of small patches to compute shuffle masks for the couple of cases where we call getShuffleCost without one. My goal is to add an invariant that all calls to getShuffleCost for fixed length vectors have a mask.
Note that this code appears to be reachable with scalable vectors, and thus we have to only pass a non-empty mask when the number of elements is precisely known.
---
Full diff: https://github.com/llvm/llvm-project/pull/85808.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+4-1)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index dc669e314a0d9a..85c8d3996bba51 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -786,9 +786,12 @@ bool VectorCombine::scalarizeVPIntrinsic(Instruction &I) {
// intrinsic
VectorType *VecTy = cast<VectorType>(VPI.getType());
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
+ SmallVector<int> Mask;
+ if (auto *FVTy = dyn_cast<FixedVectorType>(VecTy))
+ Mask.resize(FVTy->getNumElements(), 0);
InstructionCost SplatCost =
TTI.getVectorInstrCost(Instruction::InsertElement, VecTy, CostKind, 0) +
- TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy);
+ TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy, Mask);
// Calculate the cost of the VP Intrinsic
SmallVector<Type *, 4> Args;
``````````
</details>
https://github.com/llvm/llvm-project/pull/85808
More information about the llvm-commits
mailing list