Skip to content

Commit 4d1200f

Browse files
committed
Fixup! Remove IterT and always add result type in VPMulAccumulateReductionRecipe.
1 parent c0d6573 commit 4d1200f

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
@@ -1264,19 +1264,17 @@ class VPWidenRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
12641264
: VPRecipeWithIRFlags(VPDefOpcode, Operands, I), VPIRMetadata(I),
12651265
Opcode(I.getOpcode()) {}
12661266

1267-
template <typename IterT>
1268-
VPWidenRecipe(unsigned VPDefOpcode, unsigned Opcode, ArrayRef<IterT> Operands,
1269-
bool NUW, bool NSW, DebugLoc DL)
1267+
VPWidenRecipe(unsigned VPDefOpcode, unsigned Opcode,
1268+
ArrayRef<VPValue *> Operands, bool NUW, bool NSW, DebugLoc DL)
12701269
: VPRecipeWithIRFlags(VPDefOpcode, Operands, WrapFlagsTy(NUW, NSW), DL),
12711270
Opcode(Opcode) {}
12721271

12731272
public:
12741273
VPWidenRecipe(Instruction &I, ArrayRef<VPValue *> Operands)
12751274
: VPWidenRecipe(VPDef::VPWidenSC, I, Operands) {}
12761275

1277-
template <typename IterT>
1278-
VPWidenRecipe(unsigned Opcode, ArrayRef<IterT> Operands, bool NUW, bool NSW,
1279-
DebugLoc DL)
1276+
VPWidenRecipe(unsigned Opcode, ArrayRef<VPValue *> Operands, bool NUW,
1277+
bool NSW, DebugLoc DL)
12801278
: VPWidenRecipe(VPDef::VPWidenSC, Opcode, Operands, NUW, NSW, DL) {}
12811279

12821280
~VPWidenRecipe() override = default;
@@ -2669,14 +2667,15 @@ class VPMulAccumulateReductionRecipe : public VPReductionRecipe {
26692667
IsNonNeg = Ext0->isNonNeg();
26702668
}
26712669

2672-
VPMulAccumulateReductionRecipe(VPReductionRecipe *R, VPWidenRecipe *Mul)
2670+
VPMulAccumulateReductionRecipe(VPReductionRecipe *R, VPWidenRecipe *Mul,
2671+
Type *ResultTy)
26732672
: VPReductionRecipe(
26742673
VPDef::VPMulAccumulateReductionSC, R->getRecurrenceKind(),
26752674
{R->getChainOp(), Mul->getOperand(0), Mul->getOperand(1)},
26762675
R->getCondOp(), R->isOrdered(),
26772676
WrapFlagsTy(Mul->hasNoUnsignedWrap(), Mul->hasNoSignedWrap()),
26782677
R->getDebugLoc()),
2679-
ExtOp(Instruction::CastOps::CastOpsEnd) {
2678+
ExtOp(Instruction::CastOps::CastOpsEnd), ResultTy(ResultTy) {
26802679
assert(RecurrenceDescriptor::getOpcode(getRecurrenceKind()) ==
26812680
Instruction::Add &&
26822681
"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
@@ -2779,7 +2779,7 @@ tryToMatchAndCreateMulAccumulateReduction(VPReductionRecipe *Red,
27792779
RecipeA->getResultType());
27802780
// Match reduce.add(mul).
27812781
if (IsMulAccValidAndClampRange(true, Mul, nullptr, nullptr, nullptr))
2782-
return new VPMulAccumulateReductionRecipe(Red, Mul);
2782+
return new VPMulAccumulateReductionRecipe(Red, Mul, RedTy);
27832783
}
27842784
// Match reduce.add(ext(mul(ext(A), ext(B)))).
27852785
// All extend recipes must have same opcode or A == B

0 commit comments

Comments
 (0)