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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 15 19:00:18 PST 2026


================
@@ -1614,6 +1605,31 @@ 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;
+  SmallVector<VPUser *> Worklist(HeaderMask->users());
----------------
lukel97 wrote:

Thanks for the review, that's a good point. I think we actually only need the worklist of indirect users, we can just traverse the direct header mask in a separate step. I've opened up https://github.com/llvm/llvm-project/pull/181595 for this.

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


More information about the llvm-commits mailing list