@@ -916,20 +916,24 @@ LibraryManager.library = {
916
916
{ { { makeStructuralReturn ( [ 'ret' , '0' ] ) } } } ;
917
917
} ,
918
918
919
+ llvm_ctpop_i32__asm : true ,
920
+ llvm_ctpop_i32__sig : 'ii' ,
919
921
llvm_ctpop_i32 : function ( x ) {
920
922
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
921
- x = x | 0 ;
922
- x = x - ( ( x >>> 1 ) & 0x55555555 ) | 0 ;
923
- x = ( x & 0x33333333 ) + ( ( x >>> 2 ) & 0x33333333 ) | 0 ;
924
-
925
- // next line is asm.js friendly, but unfortunatelly gives WRONG result
926
- // return (((x + (x >>> 4) & 0xF0F0F0F)|0 * 0x1010101) >>> 24)|0;
927
- return ( ( ( x + ( x >>> 4 ) & 0xF0F0F0F ) * 0x1010101 ) >>> 24 ) | 0 ;
923
+ // http://bits.stephan-brumme.com/countBits.html
924
+ x = x | 0 ;
925
+ x = x - ( ( x >>> 1 ) & 0x55555555 ) | 0 ;
926
+ x = ( x & 0x33333333 ) + ( ( x >>> 2 ) & 0x33333333 ) | 0 ;
927
+ return ( Math_imul ( ( x + ( x >>> 4 ) & 252645135 /* 0xF0F0F0F, but hits uglify parse bug? */ ) , 0x1010101 ) >>> 24 ) | 0 ;
928
928
} ,
929
929
930
930
llvm_ctpop_i64__deps : [ 'llvm_ctpop_i32' ] ,
931
+ llvm_ctpop_i64__asm : true ,
932
+ llvm_ctpop_i64__sig : 'iii' ,
931
933
llvm_ctpop_i64 : function ( l , h ) {
932
- return _llvm_ctpop_i32 ( l ) + _llvm_ctpop_i32 ( h ) ;
934
+ l = l | 0 ;
935
+ h = h | 0 ;
936
+ return ( _llvm_ctpop_i32 ( l ) | 0 ) + ( _llvm_ctpop_i32 ( h ) | 0 ) | 0 ;
933
937
} ,
934
938
935
939
llvm_trap : function ( ) {
0 commit comments