Skip to content

Commit c7744a9

Browse files
committed
[ValueTracking] Add depth limit
1 parent 07493fc commit c7744a9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4882,14 +4882,17 @@ llvm::fcmpImpliesClass(CmpInst::Predicate Pred, const Function &F, Value *LHS,
48824882
}
48834883

48844884
static void computeKnownFPClassFromCond(const Value *V, Value *Cond,
4885-
bool CondIsTrue,
4885+
unsigned Depth, bool CondIsTrue,
48864886
const Instruction *CxtI,
48874887
KnownFPClass &KnownFromContext) {
48884888
Value *A, *B;
4889-
if (CondIsTrue ? match(Cond, m_LogicalAnd(m_Value(A), m_Value(B)))
4890-
: match(Cond, m_LogicalOr(m_Value(A), m_Value(B)))) {
4891-
computeKnownFPClassFromCond(V, A, CondIsTrue, CxtI, KnownFromContext);
4892-
computeKnownFPClassFromCond(V, B, CondIsTrue, CxtI, KnownFromContext);
4889+
if (Depth < MaxAnalysisRecursionDepth &&
4890+
(CondIsTrue ? match(Cond, m_LogicalAnd(m_Value(A), m_Value(B)))
4891+
: match(Cond, m_LogicalOr(m_Value(A), m_Value(B))))) {
4892+
computeKnownFPClassFromCond(V, A, Depth + 1, CondIsTrue, CxtI,
4893+
KnownFromContext);
4894+
computeKnownFPClassFromCond(V, B, Depth + 1, CondIsTrue, CxtI,
4895+
KnownFromContext);
48934896
return;
48944897
}
48954898
CmpInst::Predicate Pred;
@@ -4932,13 +4935,13 @@ static KnownFPClass computeKnownFPClassFromContext(const Value *V,
49324935

49334936
BasicBlockEdge Edge0(BI->getParent(), BI->getSuccessor(0));
49344937
if (Q.DT->dominates(Edge0, Q.CxtI->getParent()))
4935-
computeKnownFPClassFromCond(V, Cond, /*CondIsTrue=*/true, Q.CxtI,
4936-
KnownFromContext);
4938+
computeKnownFPClassFromCond(V, Cond, /*Depth=*/0, /*CondIsTrue=*/true,
4939+
Q.CxtI, KnownFromContext);
49374940

49384941
BasicBlockEdge Edge1(BI->getParent(), BI->getSuccessor(1));
49394942
if (Q.DT->dominates(Edge1, Q.CxtI->getParent()))
4940-
computeKnownFPClassFromCond(V, Cond, /*CondIsTrue=*/false, Q.CxtI,
4941-
KnownFromContext);
4943+
computeKnownFPClassFromCond(V, Cond, /*Depth=*/0, /*CondIsTrue=*/false,
4944+
Q.CxtI, KnownFromContext);
49424945
}
49434946
}
49444947

@@ -4960,8 +4963,8 @@ static KnownFPClass computeKnownFPClassFromContext(const Value *V,
49604963
if (!isValidAssumeForContext(I, Q.CxtI, Q.DT))
49614964
continue;
49624965

4963-
computeKnownFPClassFromCond(V, I->getArgOperand(0), /*CondIsTrue=*/true,
4964-
Q.CxtI, KnownFromContext);
4966+
computeKnownFPClassFromCond(V, I->getArgOperand(0), /*Depth=*/0,
4967+
/*CondIsTrue=*/true, Q.CxtI, KnownFromContext);
49654968
}
49664969

49674970
return KnownFromContext;

0 commit comments

Comments
 (0)