diff --git a/include/FastSIMD/ToolSet/WASM/128/f32x4.h b/include/FastSIMD/ToolSet/WASM/128/f32x4.h index 1b3fde1..a9b8e42 100644 --- a/include/FastSIMD/ToolSet/WASM/128/f32x4.h +++ b/include/FastSIMD/ToolSet/WASM/128/f32x4.h @@ -190,7 +190,15 @@ namespace FS template>> FS_FORCEINLINE f32<4, SIMD> Select( const typename f32<4, SIMD>::MaskTypeArg& mask, const f32<4, SIMD>& ifTrue, const f32<4, SIMD>& ifFalse ) { - return wasm_v128_bitselect( ifTrue.native, ifFalse.native, mask.native ); + if constexpr( FastSIMD::IsRelaxed() ) + { + // Mask lanes are all ones or all zeros, laneselect is a single blend on x64 hosts (bitselect is and/andnot/or) + return wasm_i32x4_relaxed_laneselect( ifTrue.native, ifFalse.native, mask.native ); + } + else + { + return wasm_v128_bitselect( ifTrue.native, ifFalse.native, mask.native ); + } } diff --git a/include/FastSIMD/ToolSet/WASM/128/i32x4.h b/include/FastSIMD/ToolSet/WASM/128/i32x4.h index f879354..d7f911d 100644 --- a/include/FastSIMD/ToolSet/WASM/128/i32x4.h +++ b/include/FastSIMD/ToolSet/WASM/128/i32x4.h @@ -156,7 +156,15 @@ namespace FS template>> FS_FORCEINLINE i32<4, SIMD> Select( const typename i32<4, SIMD>::MaskTypeArg& mask, const i32<4, SIMD>& ifTrue, const i32<4, SIMD>& ifFalse ) { - return wasm_v128_bitselect( ifTrue.native, ifFalse.native, mask.native ); + if constexpr( FastSIMD::IsRelaxed() ) + { + // Mask lanes are all ones or all zeros, laneselect is a single blend on x64 hosts (bitselect is and/andnot/or) + return wasm_i32x4_relaxed_laneselect( ifTrue.native, ifFalse.native, mask.native ); + } + else + { + return wasm_v128_bitselect( ifTrue.native, ifFalse.native, mask.native ); + } } template>>