[llvm] [VPlan] Remove redundant x && (y && x) -> x && y combine (PR #213219)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 03:42:48 PDT 2026


================
@@ -1188,16 +1192,9 @@ static bool simplifyLogicalRecipe(VPSingleDefRecipe *Def, VPBuilder &Builder,
   }
 
   // x && (x && y) -> x && y
-  if (match(Def, m_LogicalAnd(m_VPValue(X),
-                              m_LogicalAnd(m_Deferred(X), m_VPValue())))) {
-    Def->replaceAllUsesWith(Def->getOperand(1));
-    return true;
-  }
-
-  // x && (y && x) -> x && y
-  if (match(Def, m_LogicalAnd(m_VPValue(X),
-                              m_LogicalAnd(m_VPValue(Y), m_Deferred(X))))) {
-    Def->replaceAllUsesWith(Builder.createLogicalAnd(X, Y));
+  if (match(Def, m_c_LogicalAnd(m_VPValue(X),
+                                m_c_LogicalAnd(m_Deferred(X), m_VPValue())))) {
+    Def->replaceAllUsesWith(Def->getOperand(Def->getOperand(1) == X ? 0 : 1));
----------------
artagnon wrote:

If it's already present in the IR-PatternMatch, could introduce the m_VPValue(X, P) independently to clean up all these instances at once?

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


More information about the llvm-commits mailing list