[llvm] 1116e4f - [ValueTracking] Rename computeKnownBitsFrom{Assume -> Context} (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 05:58:32 PST 2023
Author: Nikita Popov
Date: 2023-11-28T14:57:24+01:00
New Revision: 1116e4f5dc2ba070dd655ec55231a5b21d33573f
URL: https://github.com/llvm/llvm-project/commit/1116e4f5dc2ba070dd655ec55231a5b21d33573f
DIFF: https://github.com/llvm/llvm-project/commit/1116e4f5dc2ba070dd655ec55231a5b21d33573f.diff
LOG: [ValueTracking] Rename computeKnownBitsFrom{Assume -> Context} (NFC)
In preparation for handling non-assume context-sensitive facts.
Added:
Modified:
llvm/include/llvm/Analysis/ValueTracking.h
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ValueTracking.h b/llvm/include/llvm/Analysis/ValueTracking.h
index b7e6894b1e03548..0c5b62499b253e7 100644
--- a/llvm/include/llvm/Analysis/ValueTracking.h
+++ b/llvm/include/llvm/Analysis/ValueTracking.h
@@ -89,9 +89,9 @@ void computeKnownBits(const Value *V, KnownBits &Known, unsigned Depth,
/// \p KnownOne the set of bits that are known to be one
void computeKnownBitsFromRangeMetadata(const MDNode &Ranges, KnownBits &Known);
-/// Merge bits known from assumes into Known.
-void computeKnownBitsFromAssume(const Value *V, KnownBits &Known,
- unsigned Depth, const SimplifyQuery &Q);
+/// Merge bits known from context-dependent facts into Known.
+void computeKnownBitsFromContext(const Value *V, KnownBits &Known,
+ unsigned Depth, const SimplifyQuery &Q);
/// Using KnownBits LHS/RHS produce the known bits for logic op (and/xor/or).
KnownBits analyzeKnownBitsFromAndXorOr(
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 7a232935fafbd15..ccb5ae3ba0a11dd 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -711,7 +711,7 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
}
}
-void llvm::computeKnownBitsFromAssume(const Value *V, KnownBits &Known,
+void llvm::computeKnownBitsFromContext(const Value *V, KnownBits &Known,
unsigned Depth, const SimplifyQuery &Q) {
// Use of assumptions is context-sensitive. If we don't have a context, we
// cannot use them!
@@ -1868,11 +1868,11 @@ void computeKnownBits(const Value *V, const APInt &DemandedElts,
Known.Zero.setLowBits(Log2(Alignment));
}
- // computeKnownBitsFromAssume strictly refines Known.
+ // computeKnownBitsFromContext strictly refines Known.
// Therefore, we run them after computeKnownBitsFromOperator.
- // Check whether a nearby assume intrinsic can determine some known bits.
- computeKnownBitsFromAssume(V, Known, Depth, Q);
+ // Check whether we can determine known bits from context such as assumes.
+ computeKnownBitsFromContext(V, Known, Depth, Q);
assert((Known.Zero & Known.One) == 0 && "Bits known to be one AND zero?");
}
@@ -6338,14 +6338,14 @@ computeOverflowForSignedAdd(const WithCache<const Value *> &LHS,
// CANNOT overflow. If this can be determined from the known bits of the
// operands the above signedAddMayOverflow() check will have already done so.
// The only other way to improve on the known bits is from an assumption, so
- // call computeKnownBitsFromAssume() directly.
+ // call computeKnownBitsFromContext() directly.
bool LHSOrRHSKnownNonNegative =
(LHSRange.isAllNonNegative() || RHSRange.isAllNonNegative());
bool LHSOrRHSKnownNegative =
(LHSRange.isAllNegative() || RHSRange.isAllNegative());
if (LHSOrRHSKnownNonNegative || LHSOrRHSKnownNegative) {
KnownBits AddKnown(LHSRange.getBitWidth());
- computeKnownBitsFromAssume(Add, AddKnown, /*Depth=*/0, SQ);
+ computeKnownBitsFromContext(Add, AddKnown, /*Depth=*/0, SQ);
if ((AddKnown.isNonNegative() && LHSOrRHSKnownNonNegative) ||
(AddKnown.isNegative() && LHSOrRHSKnownNegative))
return OverflowResult::NeverOverflows;
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index fa076098d63cde5..d1eab4c05287244 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1052,7 +1052,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
computeKnownBits(I->getOperand(1), RHSKnown, Depth + 1, CxtI);
computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
Known = LHSKnown & RHSKnown;
- computeKnownBitsFromAssume(I, Known, Depth, SQ.getWithInstruction(CxtI));
+ computeKnownBitsFromContext(I, Known, Depth, SQ.getWithInstruction(CxtI));
// If the client is only demanding bits that we know, return the known
// constant.
@@ -1072,7 +1072,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
computeKnownBits(I->getOperand(1), RHSKnown, Depth + 1, CxtI);
computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
Known = LHSKnown | RHSKnown;
- computeKnownBitsFromAssume(I, Known, Depth, SQ.getWithInstruction(CxtI));
+ computeKnownBitsFromContext(I, Known, Depth, SQ.getWithInstruction(CxtI));
// If the client is only demanding bits that we know, return the known
// constant.
@@ -1094,7 +1094,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
computeKnownBits(I->getOperand(1), RHSKnown, Depth + 1, CxtI);
computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
Known = LHSKnown ^ RHSKnown;
- computeKnownBitsFromAssume(I, Known, Depth, SQ.getWithInstruction(CxtI));
+ computeKnownBitsFromContext(I, Known, Depth, SQ.getWithInstruction(CxtI));
// If the client is only demanding bits that we know, return the known
// constant.
@@ -1127,7 +1127,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
Known = KnownBits::computeForAddSub(/*Add*/ true, NSW, LHSKnown, RHSKnown);
- computeKnownBitsFromAssume(I, Known, Depth, SQ.getWithInstruction(CxtI));
+ computeKnownBitsFromContext(I, Known, Depth, SQ.getWithInstruction(CxtI));
break;
}
case Instruction::Sub: {
@@ -1143,7 +1143,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
Known = KnownBits::computeForAddSub(/*Add*/ false, NSW, LHSKnown, RHSKnown);
- computeKnownBitsFromAssume(I, Known, Depth, SQ.getWithInstruction(CxtI));
+ computeKnownBitsFromContext(I, Known, Depth, SQ.getWithInstruction(CxtI));
break;
}
case Instruction::AShr: {
More information about the llvm-commits
mailing list