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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 01:15:05 PDT 2026


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

It can be subsumed by making the combine above commutative. In theory this isn't NFC as it changes the order, in practice it doesn't make a difference.


>From 2a35a3d40f77db89ef3e855323224677c14eb4da Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Fri, 31 Jul 2026 16:13:05 +0800
Subject: [PATCH] [VPlan] Remove redundant x && (y && x) -> x && y combine

It can be subsumed by making the combine above commutative. In theory this isn't NFC as it changes the order, in practice it doesn't make a difference.
---
 llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 9990fd142df02..5bb96cd070fa5 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1192,19 +1192,12 @@ 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())))) {
+  if (match(Def, m_c_LogicalAnd(m_VPValue(X),
+                                m_c_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));
-    return true;
-  }
-
   // x && !x -> 0
   if (match(Def, m_LogicalAnd(m_VPValue(X), m_Not(m_Deferred(X))))) {
     Def->replaceAllUsesWith(Plan->getFalse());



More information about the llvm-commits mailing list