# HG changeset patch # User redestad # Date 1548260725 -3600 # Node ID e422b21ca5566bd26a45157ea4767177a7b930f0 # Parent edba42d2370fd5d03c5cfa674004ad4627bed636 8217629: RegMask::find_lowest_bit can reuse count_trailing_zeros utility Reviewed-by: thartmann, neliasso diff -r edba42d2370f -r e422b21ca556 src/hotspot/share/opto/regmask.cpp --- a/src/hotspot/share/opto/regmask.cpp Wed Jan 23 10:50:27 2019 -0500 +++ b/src/hotspot/share/opto/regmask.cpp Wed Jan 23 17:25:25 2019 +0100 @@ -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; diff -r edba42d2370f -r e422b21ca556 src/hotspot/share/opto/regmask.hpp --- a/src/hotspot/share/opto/regmask.hpp Wed Jan 23 10:50:27 2019 -0500 +++ b/src/hotspot/share/opto/regmask.hpp Wed Jan 23 17:25:25 2019 +0100 @@ -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 );