[llvm] [VPlan] Remove ComputeAnyOfResult, use ComputeReductionResult. (PR #190039)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 14:03:00 PDT 2026
================
@@ -8337,9 +8335,14 @@ void LoopVectorizationPlanner::addReductionResultComputation(
VPValue *NewVal = AnyOfSelect->getOperand(1) == PhiR
? AnyOfSelect->getOperand(2)
: AnyOfSelect->getOperand(1);
+ VPIRFlags Flags(RecurKind::Or, /*IsOrdered=*/false, /*IsInLoop=*/false,
+ FastMathFlags());
+ auto *OrReduce =
+ Builder.createNaryOp(VPInstruction::ComputeReductionResult,
+ {NewExitingVPV}, Flags, ExitDL);
+ auto *Freeze = Builder.createNaryOp(Instruction::Freeze, {OrReduce});
FinalReductionResult =
- Builder.createNaryOp(VPInstruction::ComputeAnyOfResult,
- {Start, NewVal, NewExitingVPV}, ExitDL);
+ Builder.createSelect(Freeze, NewVal, Start, {}, "rdx.select");
----------------
ayalz wrote:
Would it make sense to capture the generation of this 3-recipe-pattern in a utils or builder createAnyOfReduction() helper?
Is there any benefit in retaining computeAnyOrResult as an abstract recipe, to be materialized/replaced by this 3-recipe sequence sometime prior to codegen. Removing it altogether does provide cleanup and reuses computeReductionResult clearly and consistently; the fact that it's a Boolean reduction is still conveyed in the element type, and the AnyOf kind is still conveyed by the phi recipe.
https://github.com/llvm/llvm-project/pull/190039
More information about the llvm-commits
mailing list