[llvm] [VPlan] Simplify commutative logical ops (PR #156345)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 1 08:56:38 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);
----------------
artagnon wrote:
This simplification is necessary to avoid undoing the work you just landed: the test dead-ops-cost regresses without this simplification.
https://github.com/llvm/llvm-project/pull/156345
More information about the llvm-commits
mailing list