Skip to content

Commit 995b6de

Browse files
JIT: Don't use Compiler::compFloatingPointUsed to check if FP kills are needed (#112668)
Follow-up to #108147 (comment). Add a flag for determining if `LinearScan::getKillSetForCall` can skip killing floating-point registers so that we can reduce dependencies on global `Compiler` state.
1 parent 48b566c commit 995b6de

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/coreclr/jit/lsra.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,15 +741,16 @@ class LinearScan : public LinearScanInterface
741741
void updateMaxSpill(RefPosition* refPosition);
742742
void recordMaxSpill();
743743

744+
private:
744745
// max simultaneous spill locations used of every type
745746
unsigned int maxSpill[TYP_COUNT];
746747
unsigned int currentSpill[TYP_COUNT];
747748
bool needFloatTmpForFPCall;
748749
bool needDoubleTmpForFPCall;
749750
bool needNonIntegerRegisters;
751+
bool needToKillFloatRegs;
750752

751753
#ifdef DEBUG
752-
private:
753754
//------------------------------------------------------------------------
754755
// Should we stress lsra? This uses the DOTNET_JitStressRegs variable.
755756
//

src/coreclr/jit/lsrabuild.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,9 @@ regMaskTP LinearScan::getKillSetForCall(GenTreeCall* call)
841841
}
842842

843843
// if there is no FP used, we can ignore the FP kills
844-
if (!compiler->compFloatingPointUsed)
844+
if (!needToKillFloatRegs)
845845
{
846+
assert(!compiler->compFloatingPointUsed || !enregisterLocalVars);
846847
#if defined(TARGET_XARCH)
847848

848849
#ifdef TARGET_AMD64
@@ -2332,7 +2333,6 @@ void LinearScan::buildIntervals()
23322333
// live-in at the entry to each block (this will include the incoming args on
23332334
// the first block).
23342335
VarSetOps::AssignNoCopy(compiler, currentLiveVars, VarSetOps::MakeEmpty(compiler));
2335-
const bool floatingPointUsed = compiler->compFloatingPointUsed;
23362336

23372337
for (block = startBlockSequence(); block != nullptr; block = moveToNextBlock())
23382338
{
@@ -2341,6 +2341,7 @@ void LinearScan::buildIntervals()
23412341

23422342
if (localVarsEnregistered)
23432343
{
2344+
needToKillFloatRegs = compiler->compFloatingPointUsed;
23442345
bool predBlockIsAllocated = false;
23452346
BasicBlock* const predBlock = findPredBlockForLiveIn(block, prevBlock DEBUGARG(&predBlockIsAllocated));
23462347
if (predBlock != nullptr)
@@ -2412,8 +2413,8 @@ void LinearScan::buildIntervals()
24122413
}
24132414
else
24142415
{
2415-
// If state isn't live across blocks, then reset any global Compiler state.
2416-
compiler->compFloatingPointUsed = floatingPointUsed;
2416+
// If state isn't live across blocks, set FP register kill switch per block.
2417+
needToKillFloatRegs = false;
24172418
}
24182419

24192420
// Add a dummy RefPosition to mark the block boundary.
@@ -3012,6 +3013,7 @@ RefPosition* LinearScan::BuildDef(GenTree* tree, SingleTypeRegSet dstCandidates,
30123013
if (!varTypeUsesIntReg(type))
30133014
{
30143015
compiler->compFloatingPointUsed = true;
3016+
needToKillFloatRegs = true;
30153017
}
30163018

30173019
Interval* interval = newInterval(type);

0 commit comments

Comments
 (0)