[llvm] [VPlan] Simplify (x && y) || (x && z) -> x && (y || z) (PR #156308)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 1 03:46:11 PDT 2025
================
@@ -1092,6 +1092,17 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
return;
}
+ // (x && y) || (x && z) -> x && (y || z)
+ VPBuilder Builder(Def);
+ if (match(Def, m_c_BinaryOr(m_LogicalAnd(m_VPValue(X), m_VPValue(Y)),
+ m_LogicalAnd(m_Deferred(X), m_VPValue(Z)))) &&
+ // Simplify only if one of the operands has one use to avoid creating an
+ // extra recipe.
----------------
lukel97 wrote:
@artagnon I did some digging to confirm this is indeed what InstCombine does in general for factorization:
https://github.com/llvm/llvm-project/blob/b980ff795096ce95236b3e6f0f63cc9d1510fcec/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L786-L789
https://github.com/llvm/llvm-project/pull/156308
More information about the llvm-commits
mailing list