[llvm] [VPlan] Add ComputeAnyOfResult VPInstruction (NFC) (PR #141932)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 00:42:51 PDT 2025


================
@@ -604,6 +604,20 @@ Value *VPInstruction::generate(VPTransformState &State) {
     return Builder.CreateVectorSplat(
         State.VF, State.get(getOperand(0), /*IsScalar*/ true), "broadcast");
   }
+  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());
+    Value *ReducedPartRdx = State.get(getOperand(2));
+    for (unsigned Idx = 3; Idx < getNumOperands(); ++Idx)
+      ReducedPartRdx = Builder.CreateBinOp(
+          (Instruction::BinaryOps)RecurrenceDescriptor::getOpcode(
+              RecurKind::AnyOf),
+          State.get(getOperand(Idx)), ReducedPartRdx, "bin.rdx");
+    return createAnyOfReduction(Builder, ReducedPartRdx,
+                                State.get(getOperand(1), VPLane(0)), OrigPhi);
+  }
----------------
Mel-Chen wrote:

Do you think it’s worth unifying `ComputeAnyOfResult` and `ComputeFindLastIVResult` so they can share a common recipe?
Or would you prefer to avoid passing RecurrenceKind into the recipe?

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


More information about the llvm-commits mailing list