Skip to content

Commit c0d6573

Browse files
committed
!fixup getResultType() in VPMulAccumulateReductionRecipe.
1 parent 39f14c4 commit c0d6573

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
@@ -2630,7 +2630,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
26302630
bool IsNonNeg = false;
26312631

26322632
/// The scalar type after extending.
2633-
Type *ResultTy;
2633+
Type *ResultTy = nullptr;
26342634

26352635
/// For cloning VPMulAccumulateReductionRecipe.
26362636
VPMulAccumulateReductionRecipe(VPMulAccumulateReductionRecipe *MulAcc)
@@ -2706,11 +2706,7 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
27062706
VPSlotTracker &SlotTracker) const override;
27072707
#endif
27082708

2709-
Type *getResultType() const {
2710-
assert(isExtended() && "Only support getResultType when this recipe "
2711-
"is implicitly extend.");
2712-
return ResultTy;
2713-
}
2709+
Type *getResultType() const { return ResultTy; }
27142710

27152711
/// The first vector value to be extended and reduced.
27162712
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
@@ -2557,8 +2557,10 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
25572557
ToRemove.push_back(VPI);
25582558
}
25592559
for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
2560-
if (auto *ExtRed = dyn_cast<VPExtendedReductionRecipe>(&R))
2560+
if (auto *ExtRed = dyn_cast<VPExtendedReductionRecipe>(&R)) {
25612561
expandVPExtendedReduction(ExtRed);
2562+
continue;
2563+
}
25622564
if (auto *MulAcc = dyn_cast<VPMulAccumulateReductionRecipe>(&R))
25632565
expandVPMulAccumulateReduction(MulAcc);
25642566
}

0 commit comments

Comments
 (0)