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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 12:47:08 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)))
----------------
topperc wrote:

You can use m_Value() instead of m_Value(A/B). You don't need to recapture the variables.

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


More information about the llvm-commits mailing list