[ValueTracking] Check non-zero operator before dominating condition (NFC)
authorNikita Popov <npopov@redhat.com>
Fri, 21 Jul 2023 13:24:08 +0000 (15:24 +0200)
committerNikita Popov <npopov@redhat.com>
Fri, 21 Jul 2023 13:56:41 +0000 (15:56 +0200)
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

index 62f7c54..3dd5116 100644 (file)
@@ -2856,13 +2856,14 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
     }
   }
 
+  if (const auto *I = dyn_cast<Operator>(V))
+    if (isKnownNonZeroFromOperator(I, DemandedElts, Depth, Q))
+      return true;
+
   if (!isa<Constant>(V) &&
       isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT))
     return true;
 
-  if (const auto *I = dyn_cast<Operator>(V))
-    return isKnownNonZeroFromOperator(I, DemandedElts, Depth, Q);
-
   return false;
 }