[llvm] [ValueTracking] Strip computeKnownBits variant from ABI (NFC) (PR #225478)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 11:45:53 PDT 2026
https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/225478
>From ccc643b58d4d030f3ead37508f9c131435d3c4d9 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Tue, 22 Sep 2026 19:31:32 +0100
Subject: [PATCH 1/2] [ValueTracking] Strip computeKnownBits variant from ABI
(NFC)
A static function is sufficient.
---
llvm/include/llvm/Analysis/ValueTracking.h | 3 ---
llvm/lib/Analysis/ValueTracking.cpp | 9 ++++++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 965b69cae0db0..239400dac00fe 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -83,9 +83,6 @@ LLVM_ABI KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
bool UseInstrInfo = true,
unsigned Depth = 0);
-LLVM_ABI KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
- const SimplifyQuery &Q, unsigned Depth = 0);
-
LLVM_ABI KnownBits computeKnownBits(const Value *V, const SimplifyQuery &Q,
unsigned Depth = 0);
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 1286130cf5d94..3e03740e10fc7 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -143,6 +143,9 @@ static void computeKnownBits(const Value *V, const APInt &DemandedElts,
KnownBits &Known, const SimplifyQuery &Q,
unsigned Depth);
+static KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
+ const SimplifyQuery &Q, unsigned Depth);
+
void llvm::computeKnownBits(const Value *V, KnownBits &Known,
const SimplifyQuery &Q, unsigned Depth) {
// Since the number of lanes in a scalable vector is unknown at compile time,
@@ -176,7 +179,7 @@ KnownBits llvm::computeKnownBits(const Value *V, const APInt &DemandedElts,
const Instruction *CxtI,
const DominatorTree *DT, bool UseInstrInfo,
unsigned Depth) {
- return computeKnownBits(
+ return ::computeKnownBits(
V, DemandedElts,
SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo), Depth);
}
@@ -2526,8 +2529,8 @@ static void computeKnownBitsFromOperator(const Operator *I,
/// Determine which bits of V are known to be either zero or one and return
/// them.
-KnownBits llvm::computeKnownBits(const Value *V, const APInt &DemandedElts,
- const SimplifyQuery &Q, unsigned Depth) {
+static KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
+ const SimplifyQuery &Q, unsigned Depth) {
KnownBits Known(getBitWidth(V->getType(), Q.DL));
::computeKnownBits(V, DemandedElts, Known, Q, Depth);
return Known;
>From 5340e6eee81b5b6012981901e5aad2479e9f92aa Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Tue, 22 Sep 2026 19:43:52 +0100
Subject: [PATCH 2/2] [ValueTracking] Fix thinko; removed wrong fn
---
llvm/include/llvm/Analysis/ValueTracking.h | 8 +-------
llvm/lib/Analysis/ValueTracking.cpp | 17 ++---------------
2 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index 239400dac00fe..e71f77942db9b 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -74,14 +74,8 @@ LLVM_ABI KnownBits computeKnownBits(const Value *V, const DataLayout &DL,
bool UseInstrInfo = true,
unsigned Depth = 0);
-/// Returns the known bits rather than passing by reference.
LLVM_ABI KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
- const DataLayout &DL,
- AssumptionCache *AC = nullptr,
- const Instruction *CxtI = nullptr,
- const DominatorTree *DT = nullptr,
- bool UseInstrInfo = true,
- unsigned Depth = 0);
+ const SimplifyQuery &Q, unsigned Depth = 0);
LLVM_ABI KnownBits computeKnownBits(const Value *V, const SimplifyQuery &Q,
unsigned Depth = 0);
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3e03740e10fc7..44ba5bdc4c602 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -143,9 +143,6 @@ static void computeKnownBits(const Value *V, const APInt &DemandedElts,
KnownBits &Known, const SimplifyQuery &Q,
unsigned Depth);
-static KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
- const SimplifyQuery &Q, unsigned Depth);
-
void llvm::computeKnownBits(const Value *V, KnownBits &Known,
const SimplifyQuery &Q, unsigned Depth) {
// Since the number of lanes in a scalable vector is unknown at compile time,
@@ -174,16 +171,6 @@ KnownBits llvm::computeKnownBits(const Value *V, const DataLayout &DL,
V, SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo), Depth);
}
-KnownBits llvm::computeKnownBits(const Value *V, const APInt &DemandedElts,
- const DataLayout &DL, AssumptionCache *AC,
- const Instruction *CxtI,
- const DominatorTree *DT, bool UseInstrInfo,
- unsigned Depth) {
- return ::computeKnownBits(
- V, DemandedElts,
- SimplifyQuery(DL, DT, AC, safeCxtI(V, CxtI), UseInstrInfo), Depth);
-}
-
static NoCommonBitsSetResult
haveNoCommonBitsSetSpecialCases(const Value *LHS, const Value *RHS,
const SimplifyQuery &SQ) {
@@ -2529,8 +2516,8 @@ static void computeKnownBitsFromOperator(const Operator *I,
/// Determine which bits of V are known to be either zero or one and return
/// them.
-static KnownBits computeKnownBits(const Value *V, const APInt &DemandedElts,
- const SimplifyQuery &Q, unsigned Depth) {
+KnownBits llvm::computeKnownBits(const Value *V, const APInt &DemandedElts,
+ const SimplifyQuery &Q, unsigned Depth) {
KnownBits Known(getBitWidth(V->getType(), Q.DL));
::computeKnownBits(V, DemandedElts, Known, Q, Depth);
return Known;
More information about the llvm-commits
mailing list