8217629: RegMask::find_lowest_bit can reuse count_trailing_zeros utility

Reviewed-by: thartmann, neliasso
This commit is contained in:
Claes Redestad 2019-01-23 17:25:25 +01:00
parent d783c7a2d8
commit 199b29c58e
2 changed files with 5 additions and 31 deletions

View File

@ -33,35 +33,6 @@
#define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */
//-------------Non-zero bit search methods used by RegMask---------------------
// Find lowest 1, or return 32 if empty
int find_lowest_bit( uint32_t mask ) {
int n = 0;
if( (mask & 0xffff) == 0 ) {
mask >>= 16;
n += 16;
}
if( (mask & 0xff) == 0 ) {
mask >>= 8;
n += 8;
}
if( (mask & 0xf) == 0 ) {
mask >>= 4;
n += 4;
}
if( (mask & 0x3) == 0 ) {
mask >>= 2;
n += 2;
}
if( (mask & 0x1) == 0 ) {
mask >>= 1;
n += 1;
}
if( mask == 0 ) {
n = 32;
}
return n;
}
// Find highest 1, or return 32 if empty
int find_highest_bit( uint32_t mask ) {
int n = 0;

View File

@ -27,6 +27,7 @@
#include "code/vmreg.hpp"
#include "opto/optoreg.hpp"
#include "utilities/count_trailing_zeros.hpp"
// Some fun naming (textual) substitutions:
//
@ -45,8 +46,10 @@
// numregs in chaitin ==> proper degree in chaitin
//-------------Non-zero bit search methods used by RegMask---------------------
// Find lowest 1, or return 32 if empty
int find_lowest_bit( uint32_t mask );
// Find lowest 1, undefined if empty/0
static int find_lowest_bit(uint32_t mask) {
return count_trailing_zeros(mask);
}
// Find highest 1, or return 32 if empty
int find_highest_bit( uint32_t mask );