[llvm] [LV][RFC] Generating conditional VPBB that will be skip when the mask is inactive in VPlan. (PR #141900)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 23:48:25 PDT 2025


================
@@ -2130,6 +2130,25 @@ void VPlanTransforms::addActiveLaneMask(
     HeaderMask->replaceAllUsesWith(LaneMask);
 }
 
+/// If the header mask is replaced by EVL, peel the \p HeaderMask out of
+/// the blockInMasks.
+static bool replaceHeaderMaskToEVL(VPValue *HeaderMask, VPRecipeBase *R) {
+  using namespace llvm::VPlanPatternMatch;
+  VPValue *EdgeMask;
+  if (!R)
+    return false;
+  if (match(R, m_Binary<VPInstruction::BranchOnCount>(
+                   m_VPInstruction<VPInstruction::AnyOf>(
+                       m_Binary<VPInstruction::LogicalAnd>(
+                           m_Specific(HeaderMask), m_VPValue(EdgeMask))),
+                   m_VPValue()))) {
+
+    cast<VPInstruction>(R->getOperand(0))->setOperand(0, EdgeMask);
----------------
ElvisWang123 wrote:

The `AnyOf(%mask)` can lower to `vcpop.m`. Not sure if VPOptimizer can handle this properly or not.
If not, need to put this pass before EVL transformations and using vp.reduce.or.

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


More information about the llvm-commits mailing list