[llvm] [VPlan] Simplify worklist in reassociateHeaderMask. NFC (PR #181595)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 17 06:05:28 PST 2026


================
@@ -1623,27 +1607,29 @@ 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.
+/// header mask to be simplified further when tail folding, e.g. in
+/// optimizeEVLMasks.
 static void reassociateHeaderMask(VPlan &Plan) {
   VPValue *HeaderMask = vputils::findHeaderMask(Plan);
   if (!HeaderMask)
     return;
-  SmallVector<VPUser *> Worklist(HeaderMask->users());
+
+  SmallVector<VPUser *> Worklist;
+  for (VPUser *U : HeaderMask->users())
+    if (match(U, m_LogicalAnd(m_Specific(HeaderMask), m_VPValue())))
+      append_range(Worklist, cast<VPSingleDefRecipe>(U)->users());
----------------
lukel97 wrote:

Also noting that we could use m_c_LogicalAnd here, but trying it out there didn't seem to be any diff on the in-tree tests.

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


More information about the llvm-commits mailing list