Skip to content

Commit d1e2305

Browse files
committed
[ValueTracking] Fix release build
Move the declaration of the Ty variable outside the NDEBUG guard and make use of it in the remainder of the function.
1 parent 6503b01 commit d1e2305

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,9 +2863,9 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
28632863
/// Supports values with integer or pointer type and vectors of integers.
28642864
bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
28652865
const SimplifyQuery &Q) {
2866+
Type *Ty = V->getType();
28662867

28672868
#ifndef NDEBUG
2868-
Type *Ty = V->getType();
28692869
assert(Depth <= MaxAnalysisRecursionDepth && "Limit Search Depth");
28702870

28712871
if (auto *FVTy = dyn_cast<FixedVectorType>(Ty)) {
@@ -2887,7 +2887,7 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
28872887

28882888
// For constant vectors, check that all elements are undefined or known
28892889
// non-zero to determine that the whole vector is known non-zero.
2890-
if (auto *VecTy = dyn_cast<FixedVectorType>(C->getType())) {
2890+
if (auto *VecTy = dyn_cast<FixedVectorType>(Ty)) {
28912891
for (unsigned i = 0, e = VecTy->getNumElements(); i != e; ++i) {
28922892
if (!DemandedElts[i])
28932893
continue;
@@ -2918,7 +2918,7 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
29182918
if (MDNode *Ranges = Q.IIQ.getMetadata(I, LLVMContext::MD_range)) {
29192919
// If the possible ranges don't contain zero, then the value is
29202920
// definitely non-zero.
2921-
assert(V->getType()->isIntOrIntVectorTy() && "Range on non-integer?");
2921+
assert(Ty->isIntOrIntVectorTy() && "Range on non-integer?");
29222922
const APInt ZeroValue(Ty->getScalarSizeInBits(), 0);
29232923
if (rangeMetadataExcludesValue(Ranges, ZeroValue))
29242924
return true;
@@ -2934,7 +2934,7 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
29342934

29352935
// Check for pointer simplifications.
29362936

2937-
if (PointerType *PtrTy = dyn_cast<PointerType>(V->getType())) {
2937+
if (PointerType *PtrTy = dyn_cast<PointerType>(Ty)) {
29382938
// A byval, inalloca may not be null in a non-default addres space. A
29392939
// nonnull argument is assumed never 0.
29402940
if (const Argument *A = dyn_cast<Argument>(V)) {

0 commit comments

Comments
 (0)