[llvm] [VPlan] Split out optimizeEVLMasks. NFC (PR #174925)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 10 02:37:10 PST 2026


================
@@ -2995,8 +2979,45 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
   return nullptr;
 }
 
-/// Replace recipes with their EVL variants.
-static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
+/// Optimize away any EVL-based header masks to VP intrinsic based recipes.
+/// The transforms here need to preserve the original semantics.
+void VPlanTransforms::optimizeEVLMasks(VPlan &Plan) {
+  // Find the EVL-based header mask if it exists: icmp ult step-vector, EVL
+  VPValue *HeaderMask = nullptr, *EVL = nullptr;
+  for (VPRecipeBase &R : *Plan.getVectorLoopRegion()->getEntryBasicBlock()) {
+    if (match(&R, m_SpecificICmp(CmpInst::ICMP_ULT, m_StepVector(),
+                                 m_VPValue(EVL))) &&
+        match(EVL, m_EVL(m_VPValue()))) {
----------------
artagnon wrote:

I wonder if this can be folded? Is EVL = AVL->getSingleUser()?

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


More information about the llvm-commits mailing list