[llvm] [LV][EVL] Introduce MergeUntilPivot VPInstruction to enable out-loop reduction in EVL vectorization. (PR #101641)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 06:11:48 PDT 2024


================
@@ -661,7 +662,16 @@ Value *VPInstruction::generate(VPTransformState &State) {
     }
     return NewPhi;
   }
-
+  case VPInstruction::MergeUntilPivot: {
+    Value *Cond = State.get(getOperand(0), 0);
+    Value *OnTrue = State.get(getOperand(1), 0);
+    Value *OnFalse = State.get(getOperand(2), 0);
+    Value *Pivot = State.get(getOperand(3), /* IsScalar */ true);
+    assert(Pivot->getType()->isIntegerTy() && "Pivot should be an integer.");
+    return Builder.CreateIntrinsic(Intrinsic::vp_merge, {OnTrue->getType()},
----------------
Mel-Chen wrote:

I think the method of `VPWidenIntrinsicRecipe` is quite concise, and I appreciate it. Although I expressed a new perspective https://github.com/llvm/llvm-project/pull/109614#issuecomment-2396841914 that we don’t need to add an EVL recipe for every recipe, this doesn’t affect the use of `VPWidenIntrinsicRecipe` for the `vp.merge` use case.

The original reason of using `VPInstruction` was to avoid creating too many recipes. After all, I believe `merge until pivot` is not a commonly used operation.

In conclusion, switching to `VPWidenIntrinsicRecipe` is reasonable, especially if it can be reused in other places.

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


More information about the llvm-commits mailing list