[llvm] Move 0 vs known-non-zero case to isKnownNonEqual (PR #147330)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 08:45:47 PDT 2025
https://github.com/AZero13 created https://github.com/llvm/llvm-project/pull/147330
None
>From 894fadf0d1fb43ff5a5b4f97eb977a1f2ea53270 Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Mon, 7 Jul 2025 11:37:25 -0400
Subject: [PATCH] Move 0 vs known-non-zero case to isKnownNonEqual
---
llvm/lib/Analysis/ValueTracking.cpp | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 09745ed6eac6a..a8f5728c940b1 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2880,11 +2880,6 @@ static bool isNonZeroSub(const APInt &DemandedElts, const SimplifyQuery &Q,
if (matchOpWithOpEqZero(X, Y))
return true;
- // TODO: Move this case into isKnownNonEqual().
- if (auto *C = dyn_cast<Constant>(X))
- if (C->isNullValue() && isKnownNonZero(Y, DemandedElts, Q, Depth))
- return true;
-
return ::isKnownNonEqual(X, Y, DemandedElts, Q, Depth);
}
@@ -3892,6 +3887,12 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2,
if (Depth >= MaxAnalysisRecursionDepth)
return false;
+ // 0 vs known-non-zero => definitely different
+ if (match(V1, m_Zero()) && isKnownNonZero(V2, DemandedElts, Q, Depth + 1))
+ return true;
+ if (match(V2, m_Zero()) && isKnownNonZero(V1, DemandedElts, Q, Depth + 1))
+ return true;
+
// See if we can recurse through (exactly one of) our operands. This
// requires our operation be 1-to-1 and map every input value to exactly
// one output value. Such an operation is invertible.
More information about the llvm-commits
mailing list