Skip to content

Commit

Permalink
Fix for issue 55241 (#56230)
Browse files Browse the repository at this point in the history
Don't decrement our budget once we have reached 0
  • Loading branch information
briansull authored Jul 26, 2021
1 parent 2f2ed39 commit 16b4564
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,7 +2282,7 @@ ValueNum ValueNumStore::VNForMapSelectWork(
else
{
// Give up if we've run out of budget.
if (--(*pBudget) <= 0)
if (*pBudget == 0)
{
// We have to use 'nullptr' for the basic block here, because subsequent expressions
// in different blocks may find this result in the VNFunc2Map -- other expressions in
Expand All @@ -2293,6 +2293,9 @@ ValueNum ValueNumStore::VNForMapSelectWork(
return res;
}

// Reduce our budget by one
(*pBudget)--;

// If it's recursive, stop the recursion.
if (SelectIsBeingEvaluatedRecursively(arg0VN, arg1VN))
{
Expand Down Expand Up @@ -2329,9 +2332,9 @@ ValueNum ValueNumStore::VNForMapSelectWork(
assert(funcApp.m_args[1] != arg1VN); // we already checked this above.
#if FEATURE_VN_TRACE_APPLY_SELECTORS
JITDUMP(" AX2: " FMT_VN " != " FMT_VN " ==> select([" FMT_VN "]store(" FMT_VN ", " FMT_VN
", " FMT_VN "), " FMT_VN ") ==> select(" FMT_VN ", " FMT_VN ").\n",
", " FMT_VN "), " FMT_VN ") ==> select(" FMT_VN ", " FMT_VN ") remaining budget is %d.\n",
arg1VN, funcApp.m_args[1], arg0VN, funcApp.m_args[0], funcApp.m_args[1], funcApp.m_args[2],
arg1VN, funcApp.m_args[0], arg1VN);
arg1VN, funcApp.m_args[0], arg1VN, *pBudget);
#endif
// This is the equivalent of the recursive tail call:
// return VNForMapSelect(vnk, typ, funcApp.m_args[0], arg1VN);
Expand Down

0 comments on commit 16b4564

Please sign in to comment.