From 4f7e03463f34343bc4873a4c95470c22ad9888af Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 21 Jul 2023 15:24:08 +0200 Subject: [PATCH] [ValueTracking] Check non-zero operator before dominating condition (NFC) Prefer checking for non-zero operator before non-zero via dominating conditions. This is to make sure we don't have compile-time regressions when special cases that are currently part of isKnownNonZero() get moved into isKnownNonZeroFromOperator(). --- llvm/lib/Analysis/ValueTracking.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 62f7c54..3dd5116 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; } -- 2.7.4