[llvm] [VPlan] Explicitly reassociate header mask in logical and (PR #180898)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 11 01:30:47 PST 2026


================
@@ -1614,6 +1605,27 @@ void VPlanTransforms::simplifyRecipes(VPlan &Plan) {
   }
 }
 
+/// Reassociate (headermask && x) && y -> headermask && (x && y) to allow the
+/// header mask to be simplified further, e.g. in optimizeEVLMasks.
+static void reassociateHeaderMask(VPlan &Plan) {
+  VPValue *HeaderMask = vputils::findHeaderMask(Plan);
+  if (!HeaderMask)
+    return;
+  ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT(
+      Plan.getVectorLoopRegion());
+  VPValue *X, *Y;
+  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT))
----------------
fhahn wrote:

do we need RPOT + deep traversal?

Do we need to iterate over the whole plan? Can we instead just look at the users of header mask and check how they are used, looking and reassociating up to the outermost `LogicalAnd` user?

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


More information about the llvm-commits mailing list