Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
11 changes: 9 additions & 2 deletions src/coreclr/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,7 @@ class CSE_Heuristic

bool canEnregister = true;
unsigned slotCount = 1;
if (candidate->Expr()->TypeGet() == TYP_STRUCT)
if (candidate->Expr()->TypeIs(TYP_STRUCT))
{
// This is a non-enregisterable struct.
canEnregister = false;
Expand Down Expand Up @@ -2601,10 +2601,17 @@ class CSE_Heuristic
//
if (candidate->LiveAcrossCall())
{
if (candidate->Expr()->IsCnsFltOrDbl() && (CNT_CALLEE_SAVED_FLOAT == 0))
{
// We should do CSE for fp constants in case of LiveAcrossCall only when absolutely necessary
// on ABIs without callee-saved registers.
cse_use_cost += 2;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with this more surgical fix for 6.0, but if we decide to go this route then you should open an issue about revisiting the float heuristics for .NET 7. It does not really make sense to adjust the use cost of a CSE based on the contents of the tree that is being CSE'd, I think.


// If we don't have a lot of variables to enregister or we have a floating point type
// then we will likely need to spill an additional caller save register.
//
if ((enregCount < (CNT_CALLEE_ENREG * 3 / 2)) || varTypeIsFloating(candidate->Expr()->TypeGet()))
if ((enregCount < (CNT_CALLEE_ENREG * 3 / 2)) || varTypeIsFloating(candidate->Expr()))
{
// Extra cost in case we have to spill/restore a caller saved register
extra_yes_cost = BB_UNITY_WEIGHT_UNSIGNED;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5955,7 +5955,7 @@ bool Compiler::optIsProfitableToHoistableTree(GenTree* tree, unsigned lnum)
int loopVarCount;
int varInOutCount;

if (varTypeIsFloating(tree->TypeGet()))
if (varTypeIsFloating(tree))
{
hoistedExprCount = pLoopDsc->lpHoistedFPExprCount;
loopVarCount = pLoopDsc->lpLoopVarFPCount;
Expand Down