[llvm] [Analysis][ValueTracking] Unify most of the tracking between AssumptionCache and DomConditionCache (PR #83161)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 4 10:55:49 PST 2024
================
@@ -82,64 +76,23 @@ findAffectedValues(CallBase *CI, TargetTransformInfo *TTI,
if (Bundle.getTagName() == "separate_storage") {
assert(Bundle.Inputs.size() == 2 &&
"separate_storage must have two args");
- AddAffected(getUnderlyingObject(Bundle.Inputs[0]), Idx);
- AddAffected(getUnderlyingObject(Bundle.Inputs[1]), Idx);
+ AddAffectedVal(getUnderlyingObject(Bundle.Inputs[0]), Idx);
+ AddAffectedVal(getUnderlyingObject(Bundle.Inputs[1]), Idx);
} else if (Bundle.Inputs.size() > ABA_WasOn &&
Bundle.getTagName() != IgnoreBundleTag)
- AddAffected(Bundle.Inputs[ABA_WasOn], Idx);
+ AddAffectedVal(Bundle.Inputs[ABA_WasOn], Idx);
}
- Value *Cond = CI->getArgOperand(0), *A, *B;
- AddAffected(Cond);
- if (match(Cond, m_Not(m_Value(A))))
- AddAffected(A);
-
- CmpInst::Predicate Pred;
- if (match(Cond, m_Cmp(Pred, m_Value(A), m_Value(B)))) {
- AddAffected(A);
- AddAffected(B);
-
- if (Pred == ICmpInst::ICMP_EQ) {
- if (match(B, m_ConstantInt())) {
- Value *X;
- // (X & C) or (X | C) or (X ^ C).
- // (X << C) or (X >>_s C) or (X >>_u C).
- if (match(A, m_BitwiseLogic(m_Value(X), m_ConstantInt())) ||
- match(A, m_Shift(m_Value(X), m_ConstantInt())))
- AddAffected(X);
- }
- } else if (Pred == ICmpInst::ICMP_NE) {
- Value *X;
- // Handle (X & pow2 != 0).
- if (match(A, m_And(m_Value(X), m_Power2())) && match(B, m_Zero()))
- AddAffected(X);
- } else if (Pred == ICmpInst::ICMP_ULT) {
- Value *X;
- // Handle (A + C1) u< C2, which is the canonical form of A > C3 && A < C4,
- // and recognized by LVI at least.
- if (match(A, m_Add(m_Value(X), m_ConstantInt())) &&
- match(B, m_ConstantInt()))
- AddAffected(X);
- } else if (CmpInst::isFPPredicate(Pred)) {
- // fcmp fneg(x), y
- // fcmp fabs(x), y
- // fcmp fneg(fabs(x)), y
- if (match(A, m_FNeg(m_Value(A))))
- AddAffected(A);
- if (match(A, m_FAbs(m_Value(A))))
- AddAffected(A);
- }
- } else if (match(Cond, m_Intrinsic<Intrinsic::is_fpclass>(m_Value(A),
- m_Value(B)))) {
- AddAffected(A);
- }
+ Value *Cond = CI->getArgOperand(0);
+ llvm::findValuesAffectedByCondition(Cond, /*IsAssume*/ true, InsertAffected);
----------------
dtcxzyw wrote:
https://github.com/llvm/llvm-project/pull/76360#discussion_r1441670829
https://github.com/llvm/llvm-project/pull/83161
More information about the llvm-commits
mailing list