@@ -55,7 +55,7 @@ inline typename std::enable_if<
5555 !(std::is_signed<Integer>::value) &&
5656 (std::numeric_limits<Integer>::digits==64 )
5757 , unsigned >::type
58- msb ( Integer const & x){
58+ msb ( Integer const x){
5959
6060 if (!x) return 64 ;
6161
@@ -73,17 +73,18 @@ msb( Integer const& x){
7373
7474 #else
7575
76+ Integer _x
7677 unsigned y;
7778 int n = 64 ;
7879
79- y = x >>32 ; if (y != 0 ) {n = n -32 ; x = y;}
80- y = x >>16 ; if (y != 0 ) {n = n -16 ; x = y;}
81- y = x >> 8 ; if (y != 0 ) {n = n - 8 ; x = y;}
82- y = x >> 4 ; if (y != 0 ) {n = n - 4 ; x = y;}
83- y = x >> 2 ; if (y != 0 ) {n = n - 2 ; x = y;}
84- y = x >> 1 ; if (y != 0 ) return n - 2 ;
80+ y = _x >>32 ; if (y != 0 ) {n = n -32 ; _x = y;}
81+ y = _x >>16 ; if (y != 0 ) {n = n -16 ; _x = y;}
82+ y = _x >> 8 ; if (y != 0 ) {n = n - 8 ; _x = y;}
83+ y = _x >> 4 ; if (y != 0 ) {n = n - 4 ; _x = y;}
84+ y = _x >> 2 ; if (y != 0 ) {n = n - 2 ; _x = y;}
85+ y = _x >> 1 ; if (y != 0 ) return n - 2 ;
8586
86- return 63 - n - x ;
87+ return 63 - n - _x ;
8788
8889 #endif
8990// device path will try to use
@@ -105,7 +106,7 @@ inline typename std::enable_if<
105106 !(std::is_signed<Integer>::value) &&
106107 (std::numeric_limits<Integer>::digits<=32 )
107108 , unsigned >::type
108- msb ( Integer const & x){
109+ msb ( Integer const x){
109110
110111 if (!x) return 32 ;
111112
@@ -126,12 +127,12 @@ msb( Integer const& x){
126127
127128 unsigned y;
128129 int n = 32 ;
129- y = x >>16 ; if (y != 0 ) {n = n -16 ; x = y;}
130- y = x >> 8 ; if (y != 0 ) {n = n - 8 ; x = y;}
131- y = x >> 4 ; if (y != 0 ) {n = n - 4 ; x = y;}
132- y = x >> 2 ; if (y != 0 ) {n = n - 2 ; x = y;}
133- y = x >> 1 ; if (y != 0 ) return n - 2 ;
134- return 31 - n - x ;
130+ y = _x >>16 ; if (y != 0 ) {n = n -16 ; _x = y;}
131+ y = _x >> 8 ; if (y != 0 ) {n = n - 8 ; _x = y;}
132+ y = _x >> 4 ; if (y != 0 ) {n = n - 4 ; _x = y;}
133+ y = _x >> 2 ; if (y != 0 ) {n = n - 2 ; _x = y;}
134+ y = _x >> 1 ; if (y != 0 ) return n - 2 ;
135+ return 31 - n - _x ;
135136
136137 #endif
137138#else
0 commit comments