Skip to content

Commit a02fb39

Browse files
committed
[ValueTracking] Check both operands for being 0 and then the other for isKnownNonZero
We should check both operands, not just the first one.
1 parent aec8883 commit a02fb39

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,9 +2880,10 @@ static bool isNonZeroSub(const APInt &DemandedElts, const SimplifyQuery &Q,
28802880
if (matchOpWithOpEqZero(X, Y))
28812881
return true;
28822882

2883-
// TODO: Move this case into isKnownNonEqual().
2884-
if (auto *C = dyn_cast<Constant>(X))
2885-
if (C->isNullValue() && isKnownNonZero(Y, DemandedElts, Q, Depth))
2883+
// TODO: Move these into isKnownNonEqual().
2884+
if (match(X, m_Zero()) && isKnownNonZero(Y, DemandedElts, Q, Depth))
2885+
return true;
2886+
if (match(Y, m_Zero()) && isKnownNonZero(X, DemandedElts, Q, Depth))
28862887
return true;
28872888

28882889
return ::isKnownNonEqual(X, Y, DemandedElts, Q, Depth);

0 commit comments

Comments
 (0)