[llvm] 35a1161 - [ValueTracking] Assert known bits sanity in isKnownNonZero
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 30 10:54:04 PDT 2022
Author: Philip Reames
Date: 2022-10-30T10:53:52-07:00
New Revision: 35a1161c241f39e82de1bc23d43c5faffd9f24b4
URL: https://github.com/llvm/llvm-project/commit/35a1161c241f39e82de1bc23d43c5faffd9f24b4
DIFF: https://github.com/llvm/llvm-project/commit/35a1161c241f39e82de1bc23d43c5faffd9f24b4.diff
LOG: [ValueTracking] Assert known bits sanity in isKnownNonZero
These are the same asserts we have in other query routines; cover this interface too.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 49cfff7f2a68..7605f660c0f4 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2453,6 +2453,20 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
if (isa<ScalableVectorType>(V->getType()))
return false;
+#ifndef NDEBUG
+ Type *Ty = V->getType();
+ assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth");
+
+ if (auto *FVTy = dyn_cast<FixedVectorType>(Ty)) {
+ assert(
+ FVTy->getNumElements() == DemandedElts.getBitWidth() &&
+ "DemandedElt width should equal the fixed vector number of elements");
+ } else {
+ assert(DemandedElts == APInt(1, 1) &&
+ "DemandedElt width should be 1 for scalars");
+ }
+#endif
+
if (auto *C = dyn_cast<Constant>(V)) {
if (C->isNullValue())
return false;
More information about the llvm-commits
mailing list