[llvm] [LV] Support EVL for partial reduction and VPExpressionRecipe. (PR #205741)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 09:23:39 PDT 2026
================
@@ -3149,6 +3157,28 @@ 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 VPReductionEVLRecipe later.
+ SmallVector<VPSingleDefRecipe *> ExpressionRecipes = Expr->decompose();
+ VPReductionRecipe *Red =
+ cast<VPReductionRecipe>(ExpressionRecipes.pop_back_val());
+
+ // Convert to VPReductionEVLRecipe.
+ auto *NewRed = new VPReductionEVLRecipe(
+ *Red, EVL, Mask ? Mask : Plan->getTrue(), Red->getDebugLoc());
+ NewRed->insertBefore(Expr);
+ ExpressionRecipes.push_back(NewRed);
+ auto *NewExpr =
+ new VPExpressionRecipe(Expr->getExpressionType(), ExpressionRecipes);
+
+ // Replace uses and remove the old non-EVL reduction.
+ Red->replaceAllUsesWith(NewExpr);
+ Red->eraseFromParent();
----------------
Mel-Chen wrote:
optimizeEVLMasks already handles replacing the users.
https://github.com/llvm/llvm-project/pull/205741
More information about the llvm-commits
mailing list