Skip to content

Commit 894fadf

Browse files
committed
Move 0 vs known-non-zero case to isKnownNonEqual
1 parent aec8883 commit 894fadf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,11 +2880,6 @@ 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))
2886-
return true;
2887-
28882883
return ::isKnownNonEqual(X, Y, DemandedElts, Q, Depth);
28892884
}
28902885

@@ -3892,6 +3887,12 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2,
38923887
if (Depth >= MaxAnalysisRecursionDepth)
38933888
return false;
38943889

3890+
// 0 vs known-non-zero => definitely different
3891+
if (match(V1, m_Zero()) && isKnownNonZero(V2, DemandedElts, Q, Depth + 1))
3892+
return true;
3893+
if (match(V2, m_Zero()) && isKnownNonZero(V1, DemandedElts, Q, Depth + 1))
3894+
return true;
3895+
38953896
// See if we can recurse through (exactly one of) our operands. This
38963897
// requires our operation be 1-to-1 and map every input value to exactly
38973898
// one output value. Such an operation is invertible.

0 commit comments

Comments
 (0)