diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2017-08-01 14:12:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-01 14:12:46 -0700 |
commit | 2293b72929a27df38c66a3bab26fe06e5cb804fd (patch) | |
tree | 39660b1f3a3a77f751c1afe77443250118c210e9 | |
parent | 2e0a813ee01fecc28345c296408230b9d56f6645 (diff) | |
parent | f3e980b765e38818e2e9eaae75bbbf4248db726a (diff) | |
download | coreclr-2293b72929a27df38c66a3bab26fe06e5cb804fd.tar.gz coreclr-2293b72929a27df38c66a3bab26fe06e5cb804fd.tar.bz2 coreclr-2293b72929a27df38c66a3bab26fe06e5cb804fd.zip |
Merge pull request #13109 from mikedn/range-alloc
Remove unnecessary allocations from RangeCheck
-rw-r--r-- | src/jit/rangecheck.cpp | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/src/jit/rangecheck.cpp b/src/jit/rangecheck.cpp index 427bab7c2a..8d8e4ada59 100644 --- a/src/jit/rangecheck.cpp +++ b/src/jit/rangecheck.cpp @@ -1117,15 +1117,6 @@ bool RangeCheck::ComputeDoesOverflow(BasicBlock* block, GenTreePtr stmt, GenTree return overflows; } -struct Node -{ - Range range; - Node* next; - Node() : range(Limit(Limit::keUndef)), next(nullptr) - { - } -}; - // Compute the range recursively by asking for the range of each variable in the dependency chain. // eg.: c = a + b; ask range of "a" and "b" and add the results. // If the result cannot be determined i.e., the dependency chain does not terminate in a value, @@ -1195,40 +1186,24 @@ Range RangeCheck::ComputeRange( // If phi, then compute the range for arguments, calling the result "dependent" when looping begins. else if (expr->OperGet() == GT_PHI) { - Node* cur = nullptr; - Node* head = nullptr; + Range argRange = Range(Limit(Limit::keUndef)); for (GenTreeArgList* args = expr->gtOp.gtOp1->AsArgList(); args != nullptr; args = args->Rest()) { - // Collect the range for each phi argument in a linked list. - Node* node = new (m_pCompiler->getAllocator()) Node(); - if (cur != nullptr) + if (path->Lookup(args->Current())) { - cur->next = node; - cur = cur->next; + JITDUMP("PhiArg [%06d] is already being computed\n", Compiler::dspTreeID(args->Current())); + argRange = Range(Limit(Limit::keDependent)); } else { - head = node; - cur = head; + argRange = GetRange(block, stmt, args->Current(), path, monotonic DEBUGARG(indent + 1)); } - if (path->Lookup(args->Current())) - { - JITDUMP("PhiArg [%06d] is already being computed\n", Compiler::dspTreeID(args->Current())); - cur->range = Range(Limit(Limit::keDependent)); - MergeAssertion(block, stmt, args->Current(), path, &cur->range DEBUGARG(indent + 1)); - continue; - } - cur->range = GetRange(block, stmt, args->Current(), path, monotonic DEBUGARG(indent + 1)); - MergeAssertion(block, stmt, args->Current(), path, &cur->range DEBUGARG(indent + 1)); - } - // Walk the linked list and merge the ranges. - for (cur = head; cur; cur = cur->next) - { - assert(!cur->range.LowerLimit().IsUndef()); - assert(!cur->range.UpperLimit().IsUndef()); + assert(!argRange.LowerLimit().IsUndef()); + assert(!argRange.UpperLimit().IsUndef()); + MergeAssertion(block, stmt, args->Current(), path, &argRange DEBUGARG(indent + 1)); JITDUMP("Merging ranges %s %s:", range.ToString(m_pCompiler->getAllocatorDebugOnly()), - cur->range.ToString(m_pCompiler->getAllocatorDebugOnly())); - range = RangeOps::Merge(range, cur->range, monotonic); + argRange.ToString(m_pCompiler->getAllocatorDebugOnly())); + range = RangeOps::Merge(range, argRange, monotonic); JITDUMP("%s\n", range.ToString(m_pCompiler->getAllocatorDebugOnly())); } } |