Skip to content

Commit

Permalink
Refactor computing lvaLongVars/lvaFloatVars (#82331)
Browse files Browse the repository at this point in the history
Compute them before loop hoisting, where they are actually used,
not at the beginning of value numbering.
  • Loading branch information
BruceForstall authored Feb 19, 2023
1 parent 25db651 commit 7908e8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6137,6 +6137,9 @@ class Compiler
// written to, and SZ-array element type equivalence classes updated.
void optComputeLoopSideEffects();

// Compute the sets of long and float vars (lvaLongVars, lvaFloatVars).
void optComputeInterestingVarSets();

#ifdef DEBUG
bool optAnyChildNotRemoved(unsigned loopNum);
#endif // DEBUG
Expand Down
14 changes: 8 additions & 6 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6675,6 +6675,8 @@ PhaseStatus Compiler::optHoistLoopCode()
}
#endif

optComputeInterestingVarSets();

// Consider all the loop nests, in inner-to-outer order
//
bool modified = false;
Expand Down Expand Up @@ -6829,9 +6831,8 @@ bool Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, Basi
pLoopDsc->lpHoistAddedPreheader = false;

#ifndef TARGET_64BIT
unsigned longVarsCount = VarSetOps::Count(this, lvaLongVars);

if (longVarsCount > 0)
if (!VarSetOps::IsEmpty(this, lvaLongVars))
{
// Since 64-bit variables take up two registers on 32-bit targets, we increase
// the Counts such that each TYP_LONG variable counts twice.
Expand Down Expand Up @@ -6866,9 +6867,7 @@ bool Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, Basi
}
#endif

unsigned floatVarsCount = VarSetOps::Count(this, lvaFloatVars);

if (floatVarsCount > 0)
if (!VarSetOps::IsEmpty(this, lvaFloatVars))
{
VARSET_TP loopFPVars(VarSetOps::Intersection(this, loopVars, lvaFloatVars));
VARSET_TP inOutFPVars(VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, lvaFloatVars));
Expand All @@ -6893,7 +6892,7 @@ bool Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt, Basi
}
#endif
}
else // (floatVarsCount == 0)
else // lvaFloatVars is empty
{
pLoopDsc->lpLoopVarFPCount = 0;
pLoopDsc->lpVarInOutFPCount = 0;
Expand Down Expand Up @@ -8494,7 +8493,10 @@ void Compiler::optComputeLoopSideEffects()
optComputeLoopNestSideEffects(lnum);
}
}
}

void Compiler::optComputeInterestingVarSets()
{
VarSetOps::AssignNoCopy(this, lvaFloatVars, VarSetOps::MakeEmpty(this));
#ifndef TARGET_64BIT
VarSetOps::AssignNoCopy(this, lvaLongVars, VarSetOps::MakeEmpty(this));
Expand Down

0 comments on commit 7908e8e

Please sign in to comment.