File tree 1 file changed +6
-11
lines changed
1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -238,14 +238,11 @@ export function __floatuntfdi(value: f64): u64 {
238
238
*/
239
239
// @ts -ignore: decorator
240
240
@global @inline
241
- export function __clz128 ( lo : u64 , hi : i64 ) : i32 {
242
- let h : u64 = < u64 > hi ; // reinterpret hi as unsigned
243
- if ( h == 0 ) {
244
- // If hi is 0, the leading zeros are "64 plus however many are in lo"
245
- return 64 + < i32 > i64 . clz ( lo ) ;
241
+ export function __clz128 ( lo : u64 , hi : u64 ) : i32 {
242
+ if ( hi == 0 ) {
243
+ return < i32 > clz ( lo ) + 64 ;
246
244
} else {
247
- // The top 64 bits are set => just measure their leading zeros
248
- return < i32 > i64 . clz ( h ) ;
245
+ return < i32 > clz ( hi ) ;
249
246
}
250
247
}
251
248
@@ -260,11 +257,9 @@ export function __clz128(lo: u64, hi: i64): i32 {
260
257
@global @inline
261
258
export function __ctz128 ( lo : u64 , hi : u64 ) : i32 {
262
259
if ( lo == 0 ) {
263
- // Otherwise, ctz is 64 plus ctz(hi)
264
- return 64 + < i32 > i64 . ctz ( hi ) ;
260
+ return < i32 > ctz ( hi ) + 64 ;
265
261
} else {
266
- // If the lower 64 bits are non-zero, measure ctz(lo)
267
- return < i32 > i64 . ctz ( lo ) ;
262
+ return < i32 > ctz ( lo ) ;
268
263
}
269
264
}
270
265
You can’t perform that action at this time.
0 commit comments