[llvm] [ValueTracking] Fixup bugprone logic in non-zero of `select`/`phi`; NFC (PR #69623)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 19 13:59:38 PDT 2023
================
@@ -2666,15 +2666,21 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
// The condition of the select dominates the true/false arm. Check if the
// condition implies that a given arm is non-zero.
- Value *X;
+ Value *X, *Y;
CmpInst::Predicate Pred;
- if (!match(I->getOperand(0), m_c_ICmp(Pred, m_Specific(Op), m_Value(X))))
+ if (!match(I->getOperand(0), m_ICmp(Pred, m_Value(X), m_Value(Y))))
+ return false;
+ if (Y == Op) {
+ Pred = ICmpInst::getSwappedPredicate(Pred);
+ std::swap(X, Y);
+ }
----------------
goldsteinn wrote:
:/ forgot that `m_c_ICmp` does the pred swapping for us
https://github.com/llvm/llvm-project/pull/69623
More information about the llvm-commits
mailing list