Skip to content

Commit aceb11f

Browse files
preameschencha3
authored andcommitted
[VectorCombine] Add a mask for SK_Broadcast shuffle costing (llvm#85808)
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.
1 parent 0b1f2df commit aceb11f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,12 @@ bool VectorCombine::scalarizeVPIntrinsic(Instruction &I) {
786786
// intrinsic
787787
VectorType *VecTy = cast<VectorType>(VPI.getType());
788788
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
789+
SmallVector<int> Mask;
790+
if (auto *FVTy = dyn_cast<FixedVectorType>(VecTy))
791+
Mask.resize(FVTy->getNumElements(), 0);
789792
InstructionCost SplatCost =
790793
TTI.getVectorInstrCost(Instruction::InsertElement, VecTy, CostKind, 0) +
791-
TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy);
794+
TTI.getShuffleCost(TargetTransformInfo::SK_Broadcast, VecTy, Mask);
792795

793796
// Calculate the cost of the VP Intrinsic
794797
SmallVector<Type *, 4> Args;

0 commit comments

Comments
 (0)