Skip to content

Commit 4585efa

Browse files
committed
[SLP][REVEC] Make getGatherCost support vector instructions.
Fix "Vector size mismatch" from LLVM :: Transforms/SLPVectorizer/X86/alternate-cmp-swapped-pred.ll LLVM :: Transforms/SLPVectorizer/X86/insert-element-build-vector-inseltpoison.ll LLVM :: Transforms/SLPVectorizer/X86/insert-element-build-vector.ll LLVM :: Transforms/SLPVectorizer/X86/reduction-logical.ll LLVM :: Transforms/SLPVectorizer/X86/reorder-clustered-node.ll
1 parent 0f80a7c commit 4585efa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11358,7 +11358,8 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1135811358
// Find the cost of inserting/extracting values from the vector.
1135911359
// Check if the same elements are inserted several times and count them as
1136011360
// shuffle candidates.
11361-
APInt ShuffledElements = APInt::getZero(VL.size());
11361+
unsigned ScalarTyNumElements = getNumElements(ScalarTy);
11362+
APInt ShuffledElements = APInt::getZero(VecTy->getNumElements());
1136211363
DenseMap<Value *, unsigned> UniqueElements;
1136311364
constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
1136411365
InstructionCost Cost;
@@ -11378,7 +11379,8 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1137811379
Value *V = VL[I];
1137911380
// No need to shuffle duplicates for constants.
1138011381
if ((ForPoisonSrc && isConstant(V)) || isa<UndefValue>(V)) {
11381-
ShuffledElements.setBit(I);
11382+
for (unsigned J = 0; J != ScalarTyNumElements; ++J)
11383+
ShuffledElements.setBit(I * ScalarTyNumElements + J);
1138211384
ShuffleMask[I] = isa<PoisonValue>(V) ? PoisonMaskElem : I;
1138311385
continue;
1138411386
}
@@ -11391,7 +11393,8 @@ InstructionCost BoUpSLP::getGatherCost(ArrayRef<Value *> VL, bool ForPoisonSrc,
1139111393
}
1139211394

1139311395
DuplicateNonConst = true;
11394-
ShuffledElements.setBit(I);
11396+
for (unsigned J = 0; J != ScalarTyNumElements; ++J)
11397+
ShuffledElements.setBit(I * ScalarTyNumElements + J);
1139511398
ShuffleMask[I] = Res.first->second;
1139611399
}
1139711400
if (ForPoisonSrc)

0 commit comments

Comments
 (0)