[llvm] [VPlan] Replace PhiR operand of ComputeAnyOfResult with VPIRFlags. (PR #175657)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 16 08:32:43 PST 2026


================
@@ -702,17 +715,22 @@ Value *VPInstruction::generate(VPTransformState &State) {
                                        Builder.getInt32(0));
   }
   case VPInstruction::ComputeAnyOfResult: {
-    // FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary
-    // and will be removed by breaking up the recipe further.
-    auto *PhiR = cast<VPReductionPHIRecipe>(getOperand(0));
-    auto *OrigPhi = cast<PHINode>(PhiR->getUnderlyingValue());
+    // Operands: Start, NewVal, followed by reduction parts.
+    Value *InitVal = State.get(getOperand(0), VPLane(0));
+    Value *NewVal = State.get(getOperand(1), VPLane(0));
     Value *ReducedPartRdx = State.get(getOperand(2));
     for (unsigned Idx = 3; Idx < getNumOperands(); ++Idx)
       ReducedPartRdx =
           Builder.CreateBinOp(Instruction::Or, State.get(getOperand(Idx)),
                               ReducedPartRdx, "bin.rdx");
-    return createAnyOfReduction(Builder, ReducedPartRdx,
-                                State.get(getOperand(1), VPLane(0)), OrigPhi);
+    // If any predicate is true it means that we want to select the new value.
+    Value *AnyOf = ReducedPartRdx->getType()->isVectorTy()
+                       ? Builder.CreateOrReduce(ReducedPartRdx)
+                       : ReducedPartRdx;
----------------
fhahn wrote:

Yep will check this as follow-up, similar to for FindIVResult; it just needs a bit more thought about how to deal with it during epilogue vectorization.

https://github.com/llvm/llvm-project/pull/175657


More information about the llvm-commits mailing list