[llvm] [ValueTracking] Compute knownbits for `(and/or cond0, cond1)` on both sides of branch (PR #82818)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 12:04:17 PST 2024


================
@@ -711,10 +711,17 @@ static void computeKnownBitsFromCond(const Value *V, Value *Cond,
                                      const SimplifyQuery &SQ, bool Invert) {
   Value *A, *B;
   if (Depth < MaxAnalysisRecursionDepth &&
-      (Invert ? match(Cond, m_LogicalOr(m_Value(A), m_Value(B)))
-              : match(Cond, m_LogicalAnd(m_Value(A), m_Value(B))))) {
-    computeKnownBitsFromCond(V, A, Known, Depth + 1, SQ, Invert);
-    computeKnownBitsFromCond(V, B, Known, Depth + 1, SQ, Invert);
+      match(Cond, m_LogicalOp(m_Value(A), m_Value(B)))) {
+    KnownBits Known2(Known.getBitWidth());
+    KnownBits Known3(Known.getBitWidth());
+    computeKnownBitsFromCond(V, A, Known2, Depth + 1, SQ, Invert);
+    computeKnownBitsFromCond(V, B, Known3, Depth + 1, SQ, Invert);
+    if (Invert ? match(Cond, m_LogicalOr(m_Value(A), m_Value(B)))
+               : match(Cond, m_LogicalAnd(m_Value(A), m_Value(B))))
+      Known = Known2.unionWith(Known3);
----------------
goldsteinn wrote:

Bah yup, Fixed.

https://github.com/llvm/llvm-project/pull/82818


More information about the llvm-commits mailing list