8217629: RegMask::find_lowest_bit can reuse count_trailing_zeros utility
authorredestad
Wed, 23 Jan 2019 17:25:25 +0100
changeset 53448 e422b21ca556
parent 53447 edba42d2370f
child 53449 ea002b56e2f3
8217629: RegMask::find_lowest_bit can reuse count_trailing_zeros utility Reviewed-by: thartmann, neliasso
src/hotspot/share/opto/regmask.cpp
src/hotspot/share/opto/regmask.hpp
--- 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;
--- 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 );