[llvm] 6d91905 - [ValueTracking] Short-circuit on unknown bits in isKnownNonEqual() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 18 06:39:29 PST 2023


Author: Nikita Popov
Date: 2023-12-18T15:36:38+01:00
New Revision: 6d91905f9786943139150bf9e2b1f10ba92444d5

URL: https://github.com/llvm/llvm-project/commit/6d91905f9786943139150bf9e2b1f10ba92444d5
DIFF: https://github.com/llvm/llvm-project/commit/6d91905f9786943139150bf9e2b1f10ba92444d5.diff

LOG: [ValueTracking] Short-circuit on unknown bits in isKnownNonEqual() (NFC)

Don't bother computing known bits for the second operand if we
know nothing about the first.

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 45fdd4eda47d76..9f709a51fd6bab 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3184,11 +3184,12 @@ static bool isKnownNonEqual(const Value *V1, const Value *V2, unsigned Depth,
     // Are any known bits in V1 contradictory to known bits in V2? If V1
     // has a known zero where V2 has a known one, they must not be equal.
     KnownBits Known1 = computeKnownBits(V1, Depth, Q);
-    KnownBits Known2 = computeKnownBits(V2, Depth, Q);
-
-    if (Known1.Zero.intersects(Known2.One) ||
-        Known2.Zero.intersects(Known1.One))
-      return true;
+    if (!Known1.isUnknown()) {
+      KnownBits Known2 = computeKnownBits(V2, Depth, Q);
+      if (Known1.Zero.intersects(Known2.One) ||
+          Known2.Zero.intersects(Known1.One))
+        return true;
+    }
   }
 
   if (isNonEqualSelect(V1, V2, Depth, Q) || isNonEqualSelect(V2, V1, Depth, Q))


        


More information about the llvm-commits mailing list