[llvm] [VPlan] Fold lhs | (headermask && rhs) -> vp.merge rhs, true, lhs, evl (PR #193511)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 23 17:51:19 PDT 2026


================
@@ -3208,6 +3208,14 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
         VPIRFlags::getDefaultFlags(Instruction::Sub), {}, DL);
   }
 
+  // lhs | (headermask && rhs) -> vp.merge rhs, true, lhs, evl
+  if (match(&CurRecipe,
+            m_c_BinaryOr(m_VPValue(LHS),
----------------
lukel97 wrote:

I'm not sure, I don't think VPlanPredicator will ever create a block-in mask with a header mask on only one arm of an or. This particular or comes from `LoopVectorizationPlanner::addReductionResultComputation` which always puts the header mask if any on the RHS.

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


More information about the llvm-commits mailing list