[llvm] [VPlan] Simplify commutative logical ops (PR #156345)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 08:49:47 PDT 2025


================
@@ -1107,6 +1092,26 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
     return Def->replaceAllUsesWith(
         Builder.createLogicalAnd(X, Builder.createOr(Y, Z)));
 
+  // OR x, 1 -> 1
+  if (match(Def, m_c_BinaryOr(m_VPValue(X), m_AllOnes())))
+    return Def->replaceAllUsesWith(Def->getOperand(Def->getOperand(0) == X));
+
+  // OR x, 0 -> x
+  if (match(Def, m_c_BinaryOr(m_VPValue(X), m_ZeroInt())))
+    return Def->replaceAllUsesWith(X);
----------------
lukel97 wrote:

These simplifications look new? Should it be split off?

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


More information about the llvm-commits mailing list