Skip to content

Commit

Permalink
JIT: Skip cost improvement check in 3-opt for exceptionally costly la…
Browse files Browse the repository at this point in the history
…youts (#110069)

Fixes #109984.
  • Loading branch information
amanasifkhalid authored Nov 22, 2024
1 parent 45b7520 commit 4045d1b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5059,9 +5059,16 @@ bool Compiler::ThreeOptLayout::TrySwappingPartitions(
std::swap(blockOrder, tempOrder);

#ifdef DEBUG
// Ensure the swap improved the overall layout. Tolerate some imprecision.
const weight_t newLayoutCost = GetLayoutCost(s1Start, s4End);
assert((newLayoutCost < currLayoutCost) || Compiler::fgProfileWeightsEqual(newLayoutCost, currLayoutCost, 0.001));
// Don't bother checking if the cost improved for exceptionally costly layouts.
// Imprecision from summing large floating-point values can falsely trigger the below assert.
constexpr weight_t maxLayoutCostToCheck = (weight_t)UINT32_MAX;
if (currLayoutCost < maxLayoutCostToCheck)
{
// Ensure the swap improved the overall layout. Tolerate some imprecision.
const weight_t newLayoutCost = GetLayoutCost(s1Start, s4End);
assert((newLayoutCost < currLayoutCost) ||
Compiler::fgProfileWeightsEqual(newLayoutCost, currLayoutCost, 0.001));
}
#endif // DEBUG

return true;
Expand Down

0 comments on commit 4045d1b

Please sign in to comment.