[llvm] [VPlan] Reassociate (x & y) & z -> x & (y & z) (PR #155383)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 09:18:46 PDT 2025


================
@@ -1120,13 +1119,11 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo,
     return;
   }
 
-  // Reassociate the header mask so it has more opportunities to be simplified.
-  // (headermask && x) && y -> headermask && (x && y)
-  if (HeaderMask && match(Def, m_LogicalAnd(m_LogicalAnd(m_Specific(HeaderMask),
-                                                         m_VPValue(X)),
-                                            m_VPValue(Y))))
+  // (x & y) & z -> x & (y & z)
+  if (match(Def, m_LogicalAnd(m_LogicalAnd(m_VPValue(X), m_VPValue(Y)),
+                              m_VPValue(Z))))
----------------
fhahn wrote:

Should this be limited to cases where `X` has multiple users? At least should have a comment of why we reassociate this way.

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


More information about the llvm-commits mailing list