Skip to content

Commit 50c3ea5

Browse files
committed
Fixes
Created using spr 1.3.5
1 parent 9682dc3 commit 50c3ea5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20818,10 +20818,20 @@ class HorizontalReduction {
2081820818
++NumVectorInstructions;
2081920819
if (ScalarTy == Builder.getInt1Ty() && ScalarTy != DestTy) {
2082020820
// Handle ctpop.
20821-
SmallVector<int> Mask(getNumElements(VecRes->getType()) +
20822-
getNumElements(Vec->getType()),
20823-
PoisonMaskElem);
20821+
unsigned VecResVF = getNumElements(VecRes->getType());
20822+
unsigned VecVF = getNumElements(Vec->getType());
20823+
SmallVector<int> Mask(VecResVF + VecVF, PoisonMaskElem);
2082420824
std::iota(Mask.begin(), Mask.end(), 0);
20825+
// Ensure that VecRes is always larger than Vec
20826+
if (VecResVF < VecVF) {
20827+
std::swap(VecRes, Vec);
20828+
std::swap(VecResVF, VecVF);
20829+
}
20830+
if (VecResVF != VecVF) {
20831+
SmallVector<int> ResizeMask(VecResVF, PoisonMaskElem);
20832+
std::iota(Mask.begin(), std::next(Mask.begin(), VecVF), 0);
20833+
Vec = Builder.CreateShuffleVector(Vec, ResizeMask);
20834+
}
2082520835
VecRes = Builder.CreateShuffleVector(VecRes, Vec, Mask, "rdx.op");
2082620836
return;
2082720837
}

0 commit comments

Comments
 (0)