File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments