diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 62f7c542a11316..3dd51165b361dd 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -2856,13 +2856,14 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth, } } + if (const auto *I = dyn_cast(V)) + if (isKnownNonZeroFromOperator(I, DemandedElts, Depth, Q)) + return true; + if (!isa(V) && isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT)) return true; - if (const auto *I = dyn_cast(V)) - return isKnownNonZeroFromOperator(I, DemandedElts, Depth, Q); - return false; }