[llvm] [InstSimplify] Use multi-op replacement when simplify `select` (PR #121708)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 5 21:30:30 PST 2025
================
@@ -4712,23 +4733,29 @@ static Value *simplifySelectWithICmpCond(Value *CondVal, Value *TrueVal,
if (match(CmpLHS, m_Or(m_Value(X), m_Value(Y))) &&
match(CmpRHS, m_Zero())) {
// (X | Y) == 0 implies X == 0 and Y == 0.
- if (Value *V = simplifySelectWithEquivalence(X, CmpRHS, TrueVal, FalseVal,
- Q, MaxRecurse))
+ if (Value *V = simplifySelectWithEquivalence(
+ {{X, CmpRHS}, {Y, CmpRHS}}, TrueVal, FalseVal, Q, MaxRecurse))
+ return V;
+ if (Value *V = simplifySelectWithEquivalence({{X, CmpRHS}}, TrueVal,
+ FalseVal, Q, MaxRecurse))
return V;
- if (Value *V = simplifySelectWithEquivalence(Y, CmpRHS, TrueVal, FalseVal,
- Q, MaxRecurse))
+ if (Value *V = simplifySelectWithEquivalence({{Y, CmpRHS}}, TrueVal,
+ FalseVal, Q, MaxRecurse))
----------------
goldsteinn wrote:
Because our simplification goal is TrueVal == FalseVal, not the complete simplification of either arm independently. If we only do the double replace we can hit some cases where we oversimplify a side and then fail to optimize our the select.
https://github.com/llvm/llvm-project/pull/121708
More information about the llvm-commits
mailing list