Skip to content

Commit 34a6f3b

Browse files
committed
!fixup getResultType() in VPMulAccumulateReductionRecipe.
1 parent 06ef087 commit 34a6f3b

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
26862686
bool IsNonNeg = false;
26872687

26882688
/// The scalar type after extending.
2689-
Type *ResultTy;
2689+
Type *ResultTy = nullptr;
26902690

26912691
/// For cloning VPMulAccumulateReductionRecipe.
26922692
VPMulAccumulateReductionRecipe(VPMulAccumulateReductionRecipe *MulAcc)
@@ -2762,11 +2762,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
27622762
VPSlotTracker &SlotTracker) const override;
27632763
#endif
27642764

2765-
Type *getResultType() const {
2766-
assert(isExtended() && "Only support getResultType when this recipe "
2767-
"is implicitly extend.");
2768-
return ResultTy;
2769-
}
2765+
Type *getResultType() const { return ResultTy; }
27702766

27712767
/// The first vector value to be extended and reduced.
27722768
VPValue *getVecOp0() const { return getOperand(1); }

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
273273
// TODO: Use info from interleave group.
274274
return V->getUnderlyingValue()->getType();
275275
})
276-
.Case<VPExtendedReductionRecipe, VPMulAccumulateReductionRecipe>(
276+
.Case<VPExtendedReductionRecipe>(
277277
[](const auto *R) { return R->getResultType(); })
278+
.Case<VPMulAccumulateReductionRecipe>([this](const auto *R) {
279+
return R->isExtended() ? R->getResultType()
280+
: inferScalarType(R->getOperand(0));
281+
})
278282
.Case<VPExpandSCEVRecipe>([](const VPExpandSCEVRecipe *R) {
279283
return R->getSCEV()->getType();
280284
})

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2530,8 +2530,10 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
25302530
ToRemove.push_back(VPI);
25312531
}
25322532
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
2533-
if (auto *ExtRed = dyn_cast<VPExtendedReductionRecipe>(&R))
2533+
if (auto *ExtRed = dyn_cast<VPExtendedReductionRecipe>(&R)) {
25342534
expandVPExtendedReduction(ExtRed);
2535+
continue;
2536+
}
25352537
if (auto *MulAcc = dyn_cast<VPMulAccumulateReductionRecipe>(&R))
25362538
expandVPMulAccumulateReduction(MulAcc);
25372539
}

0 commit comments

Comments
 (0)