Skip to content

Commit bfc5fc2

Browse files
committed
Fixup! Remove IterT and always add result type in VPMulAccumulateReductionRecipe.
1 parent 34a6f3b commit bfc5fc2

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,19 +1310,17 @@ class VPWidenRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
13101310
: VPRecipeWithIRFlags(VPDefOpcode, Operands, I), VPIRMetadata(I),
13111311
Opcode(I.getOpcode()) {}
13121312

1313-
template <typename IterT>
1314-
VPWidenRecipe(unsigned VPDefOpcode, unsigned Opcode, ArrayRef<IterT> Operands,
1315-
bool NUW, bool NSW, DebugLoc DL)
1313+
VPWidenRecipe(unsigned VPDefOpcode, unsigned Opcode,
1314+
ArrayRef<VPValue *> Operands, bool NUW, bool NSW, DebugLoc DL)
13161315
: VPRecipeWithIRFlags(VPDefOpcode, Operands, WrapFlagsTy(NUW, NSW), DL),
13171316
Opcode(Opcode) {}
13181317

13191318
public:
13201319
VPWidenRecipe(Instruction &I, ArrayRef<VPValue *> Operands)
13211320
: VPWidenRecipe(VPDef::VPWidenSC, I, Operands) {}
13221321

1323-
template <typename IterT>
1324-
VPWidenRecipe(unsigned Opcode, ArrayRef<IterT> Operands, bool NUW, bool NSW,
1325-
DebugLoc DL)
1322+
VPWidenRecipe(unsigned Opcode, ArrayRef<VPValue *> Operands, bool NUW,
1323+
bool NSW, DebugLoc DL)
13261324
: VPWidenRecipe(VPDef::VPWidenSC, Opcode, Operands, NUW, NSW, DL) {}
13271325

13281326
~VPWidenRecipe() override = default;
@@ -2725,14 +2723,15 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
27252723
IsNonNeg = Ext0->isNonNeg();
27262724
}
27272725

2728-
VPMulAccumulateReductionRecipe(VPReductionRecipe *R, VPWidenRecipe *Mul)
2726+
VPMulAccumulateReductionRecipe(VPReductionRecipe *R, VPWidenRecipe *Mul,
2727+
Type *ResultTy)
27292728
: VPReductionRecipe(
27302729
VPDef::VPMulAccumulateReductionSC, R->getRecurrenceKind(),
27312730
{R->getChainOp(), Mul->getOperand(0), Mul->getOperand(1)},
27322731
R->getCondOp(), R->isOrdered(),
27332732
WrapFlagsTy(Mul->hasNoUnsignedWrap(), Mul->hasNoSignedWrap()),
27342733
R->getDebugLoc()),
2735-
ExtOp(Instruction::CastOps::CastOpsEnd) {
2734+
ExtOp(Instruction::CastOps::CastOpsEnd), ResultTy(ResultTy) {
27362735
assert(RecurrenceDescriptor::getOpcode(getRecurrenceKind()) ==
27372736
Instruction::Add &&
27382737
"The reduction instruction in MulAccumulateReductionRecipe must be "

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,8 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
273273
// TODO: Use info from interleave group.
274274
return V->getUnderlyingValue()->getType();
275275
})
276-
.Case<VPExtendedReductionRecipe>(
276+
.Case<VPExtendedReductionRecipe, VPMulAccumulateReductionRecipe>(
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-
})
282278
.Case<VPExpandSCEVRecipe>([](const VPExpandSCEVRecipe *R) {
283279
return R->getSCEV()->getType();
284280
})

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2745,7 +2745,7 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
27452745
RecipeA->getResultType());
27462746
// Match reduce.add(mul).
27472747
if (IsMulAccValidAndClampRange(true, Mul, nullptr, nullptr, nullptr))
2748-
return new VPMulAccumulateReductionRecipe(Red, Mul);
2748+
return new VPMulAccumulateReductionRecipe(Red, Mul, RedTy);
27492749
}
27502750
// Match reduce.add(ext(mul(ext(A), ext(B)))).
27512751
// All extend recipes must have same opcode or A == B

0 commit comments

Comments
 (0)