[llvm] [VPlan] Reassociate header masks and simplify (x && y) || (x && z) -> x && (y || z) (PR #155383)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 09:20:39 PDT 2025


================
@@ -1084,6 +1086,15 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
     return;
   }
 
+  // (x && y) || (x && z) -> x && (y || z)
+  if (match(Def, m_c_BinaryOr(m_LogicalAnd(m_VPValue(X), m_VPValue(Y)),
+                              m_LogicalAnd(m_Deferred(X), m_VPValue(Z)))) &&
+      // Creating an extra recipe, so at least one arm needs to have one use.
+      (!Def->getOperand(0)->hasMoreThanOneUniqueUser() ||
+       !Def->getOperand(1)->hasMoreThanOneUniqueUser()))
----------------
artagnon wrote:

Perhaps clarify that this is a heuristic in the comment, with a quick justification?

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


More information about the llvm-commits mailing list