Skip to content

Commit f370cf1

Browse files
committed
Use IsEmpty() and IsNonEmpty()
1 parent fd18c7f commit f370cf1

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

src/coreclr/jit/lsra.cpp

+19-19
Original file line numberDiff line numberDiff line change
@@ -4040,7 +4040,7 @@ void LinearScan::processKills(RefPosition* killRefPosition)
40404040
RefPosition* nextKill = killRefPosition->nextRefPosition;
40414041

40424042
regMaskTP killedRegs = killRefPosition->registerAssignment;
4043-
while (killedRegs != RBM_NONE)
4043+
while (killedRegs.IsNonEmpty())
40444044
{
40454045
regNumber killedReg = genFirstRegNumFromMaskAndToggle(killedRegs);
40464046
RegRecord* regRecord = getRegisterRecord(killedReg);
@@ -4744,7 +4744,7 @@ void LinearScan::processBlockStartLocations(BasicBlock* currentBlock)
47444744
// Only focus on actual registers present
47454745
deadCandidates &= actualRegistersMask;
47464746

4747-
while (deadCandidates != RBM_NONE)
4747+
while (deadCandidates.IsNonEmpty())
47484748
{
47494749
regNumber reg = genFirstRegNumFromMaskAndToggle(deadCandidates);
47504750
RegRecord* physRegRecord = getRegisterRecord(reg);
@@ -4940,7 +4940,7 @@ void LinearScan::freeRegisters(regMaskTP regsToFree)
49404940

49414941
INDEBUG(dumpLsraAllocationEvent(LSRA_EVENT_FREE_REGS));
49424942
makeRegsAvailable(regsToFree);
4943-
while (regsToFree != RBM_NONE)
4943+
while (regsToFree.IsNonEmpty())
49444944
{
49454945
regNumber nextReg = genFirstRegNumFromMaskAndToggle(regsToFree);
49464946

@@ -5028,7 +5028,7 @@ void LinearScan::allocateRegistersMinimal()
50285028
// mess with the dump, since this was previously being done before the call below
50295029
// to dumpRegRecords.
50305030
regMaskTP tempRegsToMakeInactive = (regsToMakeInactive | delayRegsToMakeInactive);
5031-
while (tempRegsToMakeInactive != RBM_NONE)
5031+
while (tempRegsToMakeInactive.IsNonEmpty())
50325032
{
50335033
regNumber nextReg = genFirstRegNumFromMaskAndToggle(tempRegsToMakeInactive);
50345034
RegRecord* regRecord = getRegisterRecord(nextReg);
@@ -5102,10 +5102,10 @@ void LinearScan::allocateRegistersMinimal()
51025102
copyRegsToFree = RBM_NONE;
51035103
regsInUseThisLocation = regsInUseNextLocation;
51045104
regsInUseNextLocation = RBM_NONE;
5105-
if ((regsToFree | delayRegsToFree) != RBM_NONE)
5105+
if ((regsToFree | delayRegsToFree).IsNonEmpty())
51065106
{
51075107
freeRegisters(regsToFree);
5108-
if ((currentLocation > (prevLocation + 1)) && (delayRegsToFree != RBM_NONE))
5108+
if ((currentLocation > (prevLocation + 1)) && (delayRegsToFree.IsNonEmpty()))
51095109
{
51105110
// We should never see a delayReg that is delayed until a Location that has no RefPosition
51115111
// (that would be the RefPosition that it was supposed to interfere with).
@@ -5711,7 +5711,7 @@ void LinearScan::allocateRegisters()
57115711
// mess with the dump, since this was previously being done before the call below
57125712
// to dumpRegRecords.
57135713
regMaskTP tempRegsToMakeInactive = (regsToMakeInactive | delayRegsToMakeInactive);
5714-
while (tempRegsToMakeInactive != RBM_NONE)
5714+
while (tempRegsToMakeInactive.IsNonEmpty())
57155715
{
57165716
regNumber nextReg = genFirstRegNumFromMaskAndToggle(tempRegsToMakeInactive);
57175717
RegRecord* regRecord = getRegisterRecord(nextReg);
@@ -5789,10 +5789,10 @@ void LinearScan::allocateRegisters()
57895789
consecutiveRegsInUseThisLocation = RBM_NONE;
57905790
}
57915791
#endif
5792-
if ((regsToFree | delayRegsToFree) != RBM_NONE)
5792+
if ((regsToFree | delayRegsToFree).IsNonEmpty())
57935793
{
57945794
freeRegisters(regsToFree);
5795-
if ((currentLocation > (prevLocation + 1)) && (delayRegsToFree != RBM_NONE))
5795+
if ((currentLocation > (prevLocation + 1)) && (delayRegsToFree.IsNonEmpty()))
57965796
{
57975797
// We should never see a delayReg that is delayed until a Location that has no RefPosition
57985798
// (that would be the RefPosition that it was supposed to interfere with).
@@ -9174,15 +9174,15 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
91749174
regMaskTP sameToRegMask =
91759175
genRegMask(sameToReg, getIntervalForLocalVar(outResolutionSetVarIndex)->registerType);
91769176
if (maybeSameLivePaths &&
9177-
(((sameToRegMask & liveOutRegs) != RBM_NONE) || ((sameToRegMask & sameWriteRegs) != RBM_NONE)))
9177+
(((sameToRegMask & liveOutRegs).IsNonEmpty()) || ((sameToRegMask & sameWriteRegs).IsNonEmpty())))
91789178
{
91799179
sameToReg = REG_NA;
91809180
}
91819181
// If this register is busy because it is used by a switch table at the end of the block
91829182
// (or for Arm64, it is consumed by JCMP), we can't do the copy in this block since we can't
91839183
// insert it after the switch (or for Arm64, can't insert and overwrite the operand/source
91849184
// of operand of JCMP).
9185-
if ((sameToRegMask & consumedRegs) != RBM_NONE)
9185+
if ((sameToRegMask & consumedRegs).IsNonEmpty())
91869186
{
91879187
sameToReg = REG_NA;
91889188
}
@@ -9232,7 +9232,7 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
92329232

92339233
if (!VarSetOps::IsEmpty(compiler, sameResolutionSet))
92349234
{
9235-
if ((sameWriteRegs & diffReadRegs) != RBM_NONE)
9235+
if ((sameWriteRegs & diffReadRegs).IsNonEmpty())
92369236
{
92379237
// We cannot split the "same" and "diff" regs if the "same" set writes registers
92389238
// that must be read by the "diff" set. (Note that when these are done as a "batch"
@@ -9746,7 +9746,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
97469746

97479747
// First, find all the ones that are ready to move now
97489748
regMaskTP targetCandidates = targetRegsToDo;
9749-
while (targetCandidates != RBM_NONE)
9749+
while (targetCandidates.IsNonEmpty())
97509750
{
97519751
regNumber targetReg = genFirstRegNumFromMask(targetCandidates);
97529752
regMaskTP targetRegMask = genRegMask(targetReg);
@@ -9775,9 +9775,9 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
97759775
}
97769776

97779777
// Perform reg to reg moves
9778-
while (targetRegsToDo != RBM_NONE)
9778+
while (targetRegsToDo.IsNonEmpty())
97799779
{
9780-
while (targetRegsReady != RBM_NONE)
9780+
while (targetRegsReady.IsNonEmpty())
97819781
{
97829782
regNumber targetReg = genFirstRegNumFromMask(targetRegsReady);
97839783
regMaskTP targetRegMask = genRegMask(targetReg);
@@ -9848,7 +9848,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
98489848
}
98499849
}
98509850
}
9851-
if (targetRegsToDo != RBM_NONE)
9851+
if (targetRegsToDo.IsNonEmpty())
98529852
{
98539853
regNumber targetReg = genFirstRegNumFromMask(targetRegsToDo);
98549854
regMaskTP targetRegMask = genRegMask(targetReg);
@@ -9910,7 +9910,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
99109910
// Look at the remaining registers from targetRegsToDo (which we expect to be relatively
99119911
// small at this point) to find out what's currently in targetReg.
99129912
regMaskTP mask = targetRegsToDo;
9913-
while (mask != RBM_NONE && otherTargetReg == REG_NA)
9913+
while (mask.IsNonEmpty() && otherTargetReg == REG_NA)
99149914
{
99159915
regNumber nextReg = genFirstRegNumFromMaskAndToggle(mask);
99169916
if (location[source[nextReg]] == targetReg)
@@ -10013,7 +10013,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
1001310013

1001410014
// Finally, perform stack to reg moves
1001510015
// All the target regs will be empty at this point
10016-
while (targetRegsFromStack != RBM_NONE)
10016+
while (targetRegsFromStack.IsNonEmpty())
1001710017
{
1001810018
regNumber targetReg = genFirstRegNumFromMaskAndToggle(targetRegsFromStack);
1001910019

@@ -11525,7 +11525,7 @@ void LinearScan::dumpRegRecords()
1152511525
#endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE
1152611526
printf("%c", activeChar);
1152711527
}
11528-
else if ((genRegMask(regNum) & regsBusyUntilKill) != RBM_NONE)
11528+
else if ((genRegMask(regNum) & regsBusyUntilKill).IsNonEmpty())
1152911529
{
1153011530
printf(columnFormatArray, "Busy");
1153111531
}

src/coreclr/jit/lsrabuild.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -1847,10 +1847,7 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree, LsraLocation currentLoc
18471847
// {eax,edx} are getting killed before the def of GT_DIV. For this reason, minRegCount for
18481848
// the use position of v02 also needs to take into account the kill set of its consuming node.
18491849
regMaskTP killMask = getKillSetForNode(tree);
1850-
if (killMask != RBM_NONE)
1851-
{
1852-
minRegCountForRef += genCountBits(killMask);
1853-
}
1850+
minRegCountForRef += genCountBits(killMask);
18541851
}
18551852
else if ((newRefPosition->refType) == RefTypeDef && (newRefPosition->getInterval()->isSpecialPutArg))
18561853
{
@@ -3235,7 +3232,7 @@ void LinearScan::BuildKills(GenTree* tree, regMaskTP killMask)
32353232
// Call this even when killMask is RBM_NONE, as we have to check for some special cases
32363233
buildKillPositionsForNode(tree, currentLoc + 1, killMask);
32373234

3238-
if (killMask != RBM_NONE)
3235+
if (killMask.IsNonEmpty())
32393236
{
32403237
#if FEATURE_PARTIAL_SIMD_CALLEE_SAVE
32413238
// Build RefPositions to account for the fact that, even in a callee-save register, the upper half of any large
@@ -3339,7 +3336,7 @@ void LinearScan::BuildDefWithKills(GenTree* tree, int dstCount, SingleTypeRegSet
33393336
void LinearScan::BuildCallDefsWithKills(GenTree* tree, int dstCount, regMaskTP dstCandidates, regMaskTP killMask)
33403337
{
33413338
assert(dstCount > 0);
3342-
assert(dstCandidates != RBM_NONE);
3339+
assert(dstCandidates.IsNonEmpty());
33433340

33443341
// Build the kill RefPositions
33453342
BuildKills(tree, killMask);
@@ -3369,7 +3366,7 @@ void LinearScan::UpdatePreferencesOfDyingLocal(Interval* interval)
33693366
// _after_ the call, then we are going to prefer callee-saved registers for
33703367
// such local anyway, so there is no need to look at such local uses.
33713368
//
3372-
if (placedArgRegs == RBM_NONE)
3369+
if (placedArgRegs.IsEmpty())
33733370
{
33743371
return;
33753372
}

src/coreclr/jit/target.h

+4
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ struct regMaskTP
351351

352352
bool IsEmpty() const
353353
{
354+
#ifdef HAS_MORE_THAN_64_REGISTERS
355+
return (low | high) == RBM_NONE;
356+
#else
354357
return low == RBM_NONE;
358+
#endif
355359
}
356360

357361
bool IsNonEmpty() const

0 commit comments

Comments
 (0)