Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tune floating-point CSEs live across a call better #63903

Merged
merged 1 commit into from
Jan 24, 2022
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
15 changes: 8 additions & 7 deletions src/coreclr/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2598,17 +2598,18 @@ class CSE_Heuristic
cse_use_cost *= slotCount;
}

// If this CSE is live across a call then we may need to spill an additional caller save register
// If this CSE is live across a call then we may have additional costs
//
if (candidate->LiveAcrossCall())
{
if (candidate->Expr()->IsCnsFltOrDbl() && (CNT_CALLEE_SAVED_FLOAT == 0) &&
(candidate->CseDsc()->csdUseWtCnt <= 4))
// If we have a floating-point CSE that is both live across a call and there
// are no callee-saved FP registers available, the RA will have to spill at
// the def site and reload at the (first) use site, if the variable is a register
// candidate. Account for that.
if (varTypeIsFloating(candidate->Expr()) && (CNT_CALLEE_SAVED_FLOAT == 0) && !candidate->IsConservative())
{
// Floating point constants are expected to be contained, so unless there are more than 4 uses
// we better not to CSE them, especially on platforms without callee-saved registers
// for values living across calls
return false;
cse_def_cost += 1;
cse_use_cost += 1;
}

// If we don't have a lot of variables to enregister or we have a floating point type
Expand Down