Skip to content

Commit e194a17

Browse files
committed
[ValueTracking] Move 0 vs known-non-zero case to isKnownNonEqual
1 parent aec8883 commit e194a17

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2880,7 +2880,8 @@ 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().
2883+
// TODO: isKnownNonEqual() should catch these cases, but it is not, resulting
2884+
// in regressions.
28842885
if (auto *C = dyn_cast<Constant>(X))
28852886
if (C->isNullValue() && isKnownNonZero(Y, DemandedElts, Q, Depth))
28862887
return true;
@@ -3892,6 +3893,12 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2,
38923893
if (Depth >= MaxAnalysisRecursionDepth)
38933894
return false;
38943895

3896+
// 0 vs known-non-zero
3897+
if (match(V1, m_Zero()) && isKnownNonZero(V2, DemandedElts, Q, Depth + 1))
3898+
return true;
3899+
if (match(V2, m_Zero()) && isKnownNonZero(V1, DemandedElts, Q, Depth + 1))
3900+
return true;
3901+
38953902
// See if we can recurse through (exactly one of) our operands. This
38963903
// requires our operation be 1-to-1 and map every input value to exactly
38973904
// one output value. Such an operation is invertible.

0 commit comments

Comments
 (0)