aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorPhilip Reames <preames@rivosinc.com>2022-10-30 10:52:27 -0700
committerPhilip Reames <listmail@philipreames.com>2022-10-30 10:53:52 -0700
commit35a1161c241f39e82de1bc23d43c5faffd9f24b4 (patch)
treeb8ed4da5b2f27c3d56b5a6732363880643d73656 /llvm/lib/Analysis/ValueTracking.cpp
parent44930123e01aef3986f5a9932d6def889b60d7b5 (diff)
downloadllvm-35a1161c241f39e82de1bc23d43c5faffd9f24b4.zip
llvm-35a1161c241f39e82de1bc23d43c5faffd9f24b4.tar.gz
llvm-35a1161c241f39e82de1bc23d43c5faffd9f24b4.tar.bz2
[ValueTracking] Assert known bits sanity in isKnownNonZero
These are the same asserts we have in other query routines; cover this interface too.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 49cfff7..7605f66 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;