[llvm] [LV] Support EVL for partial reduction and VPExpressionRecipe. (PR #205741)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 18 20:53:00 PDT 2026
================
@@ -237,6 +237,29 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
Mask ? Mask : Plan->getTrue(), &EVL},
IntrR->getScalarType(), {}, {}, DL);
+ // Transforms the VPReductionRecipe inside the VPExpressionRecipe.
+ if (auto *Expr = dyn_cast<VPExpressionRecipe>(&CurRecipe))
+ if (match(Expr->getOperand(Expr->getNumOperands() - 1),
+ m_RemoveMask(HeaderMask, Mask))) {
+ // Decompose first and construct with EVL recipes later.
+ SmallVector<VPSingleDefRecipe *> ExpressionRecipes(Expr->decompose());
+
+ // Convert recipes to EVL recipes.
+ for (auto [Idx, ExprR] : enumerate(ExpressionRecipes))
+ if (auto *EVLR = cast_if_present<VPSingleDefRecipe>(
+ optimizeMaskToEVL(HeaderMask, *ExprR, EVL))) {
+ EVLR->insertBefore(ExprR);
+ ExprR->replaceAllUsesWith(EVLR);
+ ExprR->eraseFromParent();
+ ExpressionRecipes[Idx] = EVLR;
+ }
+
+ auto *NewExpr =
+ new VPExpressionRecipe(Expr->getExpressionType(), ExpressionRecipes);
+ ExpressionRecipes[ExpressionRecipes.size() - 1]->replaceAllUsesWith(
----------------
lukel97 wrote:
```suggestion
ExpressionRecipes.back()->replaceAllUsesWith(
```
https://github.com/llvm/llvm-project/pull/205741
More information about the llvm-commits
mailing list