[llvm] [VPlan] Replace PhiR operand of ComputeAnyOfResult with VPIRFlags. (PR #175657)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 18 02:06:10 PST 2026
================
@@ -8837,25 +8849,22 @@ void LoopVectorizationPlanner::addReductionResultComputation(
// with a boolean reduction phi node to check if the condition is true in
// any iteration. The final value is selected by the final
// ComputeReductionResult.
- if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RecurrenceKind)) {
- auto *Select = cast<VPRecipeBase>(*find_if(PhiR->users(), [](VPUser *U) {
- return match(U, m_Select(m_VPValue(), m_VPValue(), m_VPValue()));
- }));
- VPValue *Cmp = Select->getOperand(0);
+ if (AnyOfSelect) {
+ VPValue *Cmp = AnyOfSelect->getOperand(0);
// If the compare is checking the reduction PHI node, adjust it to check
// the start value.
if (VPRecipeBase *CmpR = Cmp->getDefiningRecipe())
CmpR->replaceUsesOfWith(PhiR, PhiR->getStartValue());
- Builder.setInsertPoint(Select);
+ Builder.setInsertPoint(AnyOfSelect);
// If the true value of the select is the reduction phi, the new value is
// selected if the negated condition is true in any iteration.
- if (Select->getOperand(1) == PhiR)
+ if (AnyOfSelect->getOperand(1) == PhiR)
Cmp = Builder.createNot(Cmp);
----------------
ayalz wrote:
Independent: can swap the (last) two operands of the select, but easier to negate `Cmp` here and fold it later?
https://github.com/llvm/llvm-project/pull/175657
More information about the llvm-commits
mailing list