[llvm] [VPlan] Explicitly reassociate header mask in logical and (PR #180898)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 08:39:06 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());
----------------
ayalz wrote:
The algorithm conceptually utilizes two distinct worklist: one of "headermask && x" recipes - initialized with all direct users of headermask that are logical AND, and the other of their users - which are indirect users of headermask that are logical AND. The former are traversed to fill the latter, while the latter are reassociated to fill the former. This is intentionally designed to be recursive, right? Would it be clearer to use two distinct homogeneous worklists.
https://github.com/llvm/llvm-project/pull/180898
More information about the llvm-commits
mailing list