[llvm] [ValueTracking] Support dominating known bits condition in and/or (PR #74728)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 23:57:03 PST 2023
================
@@ -705,28 +705,40 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
}
}
+static void computeKnownBitsFromCond(const Value *V, Value *Cond,
+ KnownBits &Known, unsigned Depth,
+ 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);
+ }
+
----------------
dtcxzyw wrote:
```suggestion
if (Depth < MaxAnalysisRecursionDepth && match(Cond, m_Not(m_Value(A))))
computeKnownBitsFromCond(V, A, Known, Depth + 1, SQ, !Invert);
```
Do you think we can benefit from handling `not`?
https://github.com/llvm/llvm-project/pull/74728
More information about the llvm-commits
mailing list