Skip to content

Commit 1b711b2

Browse files
authored
[VPlan] Clean up the function VPInstruction::generate for ComputeReductionResult, nfc (#140245)
When reducing unrolled parts, explicitly check for min/max reductions using the function RecurrenceDescriptor::isMinMaxRecurrenceKind. Only if the reduction is not min/max reduction, call RecurrenceDescriptor::getOpcode() to handle other cases via CreateBinOp. Based on #140242 Related to #118393
1 parent 172c281 commit 1b711b2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,6 @@ Value *VPInstruction::generate(VPTransformState &State) {
678678
}
679679
// Reduce all of the unrolled parts into a single vector.
680680
Value *ReducedPartRdx = RdxParts[0];
681-
unsigned Op = RdxDesc.getOpcode();
682681
if (PhiR->isOrdered()) {
683682
ReducedPartRdx = RdxParts[UF - 1];
684683
} else {
@@ -687,11 +686,12 @@ Value *VPInstruction::generate(VPTransformState &State) {
687686
Builder.setFastMathFlags(RdxDesc.getFastMathFlags());
688687
for (unsigned Part = 1; Part < UF; ++Part) {
689688
Value *RdxPart = RdxParts[Part];
690-
if (Op != Instruction::ICmp && Op != Instruction::FCmp)
691-
ReducedPartRdx = Builder.CreateBinOp(
692-
(Instruction::BinaryOps)Op, RdxPart, ReducedPartRdx, "bin.rdx");
693-
else
689+
if (RecurrenceDescriptor::isMinMaxRecurrenceKind(RK))
694690
ReducedPartRdx = createMinMaxOp(Builder, RK, ReducedPartRdx, RdxPart);
691+
else
692+
ReducedPartRdx =
693+
Builder.CreateBinOp((Instruction::BinaryOps)RdxDesc.getOpcode(),
694+
RdxPart, ReducedPartRdx, "bin.rdx");
695695
}
696696
}
697697

0 commit comments

Comments
 (0)