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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 13:35:13 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);
+  }
----------------
fhahn wrote:

With VPInstruction we cannot easily add the recurrence kind to the recipe. I think it would be good to keep the separate opcodes, especially if we add the sentinel value in https://github.com/llvm/llvm-project/pull/142291.

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


More information about the llvm-commits mailing list