Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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