diff options
Diffstat (limited to 'src/ir/bits.h')
-rw-r--r-- | src/ir/bits.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ir/bits.h b/src/ir/bits.h index a2b8fcde4..faae4c723 100644 --- a/src/ir/bits.h +++ b/src/ir/bits.h @@ -27,8 +27,9 @@ struct Bits { // get a mask to keep only the low # of bits static int32_t lowBitMask(int32_t bits) { uint32_t ret = -1; - if (bits >= 32) + if (bits >= 32) { return ret; + } return ret >> (32 - bits); } @@ -36,14 +37,17 @@ struct Bits { // bit, and all zeros from there. returns the number of masked bits, or 0 if // this is not such a mask static uint32_t getMaskedBits(uint32_t mask) { - if (mask == uint32_t(-1)) + if (mask == uint32_t(-1)) { return 32; // all the bits - if (mask == 0) + } + if (mask == 0) { return 0; // trivially not a mask + } // otherwise, see if adding one turns this into a 1-bit thing, 00011111 + 1 // => 00100000 - if (PopCount(mask + 1) != 1) + if (PopCount(mask + 1) != 1) { return 0; + } // this is indeed a mask return 32 - CountLeadingZeroes(mask); } |