@@ -136,9 +136,15 @@ fn u64_by_u64_div_rem(duo: u64, div: u64) -> (u64, u64) {
136136
137137// Whether `trifecta` or `delegate` is faster for 128 bit division depends on the speed at which a
138138// microarchitecture can multiply and divide. We decide to be optimistic and assume `trifecta` is
139- // faster if the target pointer width is at least 64.
139+ // faster if the target pointer width is at least 64. Note that this
140+ // implementation is additionally included on WebAssembly despite the typical
141+ // pointer width there being 32 because it's typically run on a 64-bit machine
142+ // that has access to faster 64-bit operations.
140143#[ cfg( all(
141- not( any( target_pointer_width = "16" , target_pointer_width = "32" ) ) ,
144+ any(
145+ target_family = "wasm" ,
146+ not( any( target_pointer_width = "16" , target_pointer_width = "32" ) ) ,
147+ ) ,
142148 not( all( not( feature = "no-asm" ) , target_arch = "x86_64" ) ) ,
143149 not( any( target_arch = "sparc" , target_arch = "sparc64" ) )
144150) ) ]
@@ -152,10 +158,14 @@ impl_trifecta!(
152158 u128
153159) ;
154160
155- // If the pointer width less than 64, then the target architecture almost certainly does not have
156- // the fast 64 to 128 bit widening multiplication needed for `trifecta` to be faster.
161+ // If the pointer width less than 64 and this isn't wasm, then the target
162+ // architecture almost certainly does not have the fast 64 to 128 bit widening
163+ // multiplication needed for `trifecta` to be faster.
157164#[ cfg( all(
158- any( target_pointer_width = "16" , target_pointer_width = "32" ) ,
165+ not( any(
166+ target_family = "wasm" ,
167+ not( any( target_pointer_width = "16" , target_pointer_width = "32" ) ) ,
168+ ) ) ,
159169 not( all( not( feature = "no-asm" ) , target_arch = "x86_64" ) ) ,
160170 not( any( target_arch = "sparc" , target_arch = "sparc64" ) )
161171) ) ]
0 commit comments