Skip to content

Commit

Permalink
Use BitOperations::PopCount() in genCountBits() (#83661)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalspathak committed Mar 21, 2023
1 parent 0c9568a commit beab6cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenarmarch.cpp
Expand Up @@ -4185,7 +4185,7 @@ void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize,
// -all callee-preserved registers in case of varargs
// -saved bool for synchronized methods

int preservedAreaSize = (2 + genCountBits(RBM_ENC_CALLEE_SAVED)) * REGSIZE_BYTES;
int preservedAreaSize = (2 + genCountBits((uint64_t)RBM_ENC_CALLEE_SAVED)) * REGSIZE_BYTES;

if (compiler->info.compIsVarArgs)
{
Expand Down
19 changes: 10 additions & 9 deletions src/coreclr/jit/compiler.hpp
Expand Up @@ -255,18 +255,19 @@ inline regMaskTP genFindLowestReg(regMaskTP value)
* A rather simple routine that counts the number of bits in a given number.
*/

template <typename T>
inline unsigned genCountBits(T bits)
inline unsigned genCountBits(uint64_t bits)
{
unsigned cnt = 0;
return BitOperations::PopCount(bits);
}

while (bits)
{
cnt++;
bits -= genFindLowestBit(bits);
}
/*****************************************************************************
*
* A rather simple routine that counts the number of bits in a given number.
*/

return cnt;
inline unsigned genCountBits(uint32_t bits)
{
return BitOperations::PopCount(bits);
}

/*****************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/emit.cpp
Expand Up @@ -1741,10 +1741,10 @@ void emitter::emitCheckIGList()
}

// An IG can have at most one of the prolog and epilog flags set.
assert(genCountBits(currIG->igFlags & (IGF_FUNCLET_PROLOG | IGF_FUNCLET_EPILOG | IGF_EPILOG)) <= 1);
assert(genCountBits((unsigned)currIG->igFlags & (IGF_FUNCLET_PROLOG | IGF_FUNCLET_EPILOG | IGF_EPILOG)) <= 1);

// An IG can't have both IGF_HAS_ALIGN and IGF_REMOVED_ALIGN.
assert(genCountBits(currIG->igFlags & (IGF_HAS_ALIGN | IGF_REMOVED_ALIGN)) <= 1);
assert(genCountBits((unsigned)currIG->igFlags & (IGF_HAS_ALIGN | IGF_REMOVED_ALIGN)) <= 1);

if (currIG->igFlags & IGF_EXTEND)
{
Expand Down

0 comments on commit beab6cd

Please sign in to comment.