diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-09-19 12:58:43 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-09-19 12:58:43 +0000 |
commit | c65dd89804d35fbd6170b61a0d1494df0576d352 (patch) | |
tree | 23afb2cb0e22463061583308301287e5dbd22bbf /llvm/lib/CodeGen | |
parent | 13bdae8541c3fc5acf6ee7de78ec5ab8446848e4 (diff) | |
download | bcm5719-llvm-c65dd89804d35fbd6170b61a0d1494df0576d352.tar.gz bcm5719-llvm-c65dd89804d35fbd6170b61a0d1494df0576d352.zip |
[DAG] Add SelectionDAG::MaxRecursionDepth constant
As commented on D67557 we have a lot of uses of depth checks all using magic numbers.
This patch adds the SelectionDAG::MaxRecursionDepth constant and moves over some general cases to use this explicitly.
Differential Revision: https://reviews.llvm.org/D67711
llvm-svn: 372315
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 7 |
3 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index edb5ecb4d3d..9de16e58e8c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -806,7 +806,7 @@ static char isNegatibleForFree(SDValue Op, bool LegalOperations, return 0; // Don't recurse exponentially. - if (Depth > 6) + if (Depth > SelectionDAG::MaxRecursionDepth) return 0; switch (Op.getOpcode()) { @@ -913,7 +913,8 @@ static SDValue GetNegatedExpression(SDValue Op, SelectionDAG &DAG, if (Op.getOpcode() == ISD::FNEG) return Op.getOperand(0); - assert(Depth <= 6 && "GetNegatedExpression doesn't match isNegatibleForFree"); + assert(Depth <= SelectionDAG::MaxRecursionDepth && + "GetNegatedExpression doesn't match isNegatibleForFree"); const TargetOptions &Options = DAG.getTarget().Options; const SDNodeFlags Flags = Op->getFlags(); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 96884bad54a..95b7fe2e1c6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2422,7 +2422,7 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts, return Known; } - if (Depth >= 6) + if (Depth >= MaxRecursionDepth) return Known; // Limit search depth. KnownBits Known2; @@ -3412,7 +3412,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts, return Val.getNumSignBits(); } - if (Depth >= 6) + if (Depth >= MaxRecursionDepth) return 1; // Limit search depth. if (!DemandedElts) @@ -3973,7 +3973,7 @@ bool SelectionDAG::isKnownNeverNaN(SDValue Op, bool SNaN, unsigned Depth) const if (getTarget().Options.NoNaNsFPMath || Op->getFlags().hasNoNaNs()) return true; - if (Depth >= 6) + if (Depth >= MaxRecursionDepth) return false; // Limit search depth. // TODO: Handle vectors. diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index cd7f64efa75..fbe4e8cca8e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -585,7 +585,7 @@ SDValue TargetLowering::SimplifyMultipleUseDemandedBits( SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth) const { // Limit search depth. - if (Depth >= 6) + if (Depth >= SelectionDAG::MaxRecursionDepth) return SDValue(); // Ignore UNDEFs. @@ -798,7 +798,8 @@ bool TargetLowering::SimplifyDemandedBits( } else if (OriginalDemandedBits == 0 || OriginalDemandedElts == 0) { // Not demanding any bits/elts from Op. return TLO.CombineTo(Op, TLO.DAG.getUNDEF(VT)); - } else if (Depth >= 6) { // Limit search depth. + } else if (Depth >= SelectionDAG::MaxRecursionDepth) { + // Limit search depth. return false; } @@ -2107,7 +2108,7 @@ bool TargetLowering::SimplifyDemandedVectorElts( } // Limit search depth. - if (Depth >= 6) + if (Depth >= SelectionDAG::MaxRecursionDepth) return false; SDLoc DL(Op); |