[ValueTracking] Early exit known non zero for phis
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 29 Sep 2020 18:48:32 +0000 (20:48 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 29 Sep 2020 19:07:36 +0000 (21:07 +0200)
After D88276 we no longer expect computeKnownBits() to prove
non-zeroness for cases where isKnownNonZero() can't, so don't
fall through to it.

llvm/lib/Analysis/ValueTracking.cpp

index 11377c4..11eb5f3 100644 (file)
@@ -2564,14 +2564,12 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
     // Check if all incoming values are non-zero using recursion.
     Query RecQ = Q;
     unsigned NewDepth = std::max(Depth, MaxAnalysisRecursionDepth - 1);
-    bool AllNonZero = llvm::all_of(PN->operands(), [&](const Use &U) {
+    return llvm::all_of(PN->operands(), [&](const Use &U) {
       if (U.get() == PN)
         return true;
       RecQ.CxtI = PN->getIncomingBlock(U)->getTerminator();
       return isKnownNonZero(U.get(), DemandedElts, NewDepth, RecQ);
     });
-    if (AllNonZero)
-      return true;
   }
   // ExtractElement
   else if (const auto *EEI = dyn_cast<ExtractElementInst>(V)) {