[llvm] [LV] Support EVL for partial reduction and VPExpressionRecipe. (PR #205741)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 20:08:32 PDT 2026


================
@@ -240,6 +240,38 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
   return nullptr;
 }
 
+// Decompose the expression recipe and transform each contained recipe into
+// an EVL recipe.
+static bool
+optimizeExpressionRecipeToEVL(VPValue *HeaderMask, VPRecipeBase &CurRecipe,
+                              VPValue &EVL,
+                              SmallVector<VPRecipeBase *> &OldRecipes) {
+
+  auto *Expr = dyn_cast<VPExpressionRecipe>(&CurRecipe);
+  if (!Expr)
+    return false;
+
+  // Decompose first and construct with EVL recipes later.
+  SmallVector<VPSingleDefRecipe *> ExpressionRecipes(Expr->decompose());
+
+  // Convert recipes to EVL recipes.
+  for (auto [Idx, R] : enumerate(ExpressionRecipes))
+    if (auto *EVLR = cast_if_present<VPSingleDefRecipe>(
+            optimizeMaskToEVL(HeaderMask, *R, EVL))) {
+      EVLR->insertBefore(R);
+      R->replaceAllUsesWith(EVLR);
+      OldRecipes.push_back(R);
+      ExpressionRecipes[Idx] = EVLR;
----------------
ElvisWang123 wrote:

Updated, thanks!

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


More information about the llvm-commits mailing list