Reimplement _mm_blendv_ps and _mm256_blendv_ps without LLVM intrinsics

This commit is contained in:
Eduardo Sánchez Muñoz 2023-10-04 19:51:08 +02:00 committed by Amanieu d'Antras
parent 2534365aee
commit cab7166474
2 changed files with 4 additions and 6 deletions

View file

@ -524,7 +524,8 @@ pub unsafe fn _mm256_blendv_pd(a: __m256d, b: __m256d, c: __m256d) -> __m256d {
#[cfg_attr(test, assert_instr(vblendvps))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm256_blendv_ps(a: __m256, b: __m256, c: __m256) -> __m256 {
vblendvps(a, b, c)
let mask: i32x8 = simd_lt(transmute::<_, i32x8>(c), i32x8::splat(0));
transmute(simd_select(mask, b.as_f32x8(), a.as_f32x8()))
}
/// Conditionally multiplies the packed single-precision (32-bit) floating-point
@ -2915,8 +2916,6 @@ extern "C" {
fn roundps256(a: __m256, b: i32) -> __m256;
#[link_name = "llvm.x86.avx.sqrt.ps.256"]
fn sqrtps256(a: __m256) -> __m256;
#[link_name = "llvm.x86.avx.blendv.ps.256"]
fn vblendvps(a: __m256, b: __m256, c: __m256) -> __m256;
#[link_name = "llvm.x86.avx.dp.ps.256"]
fn vdpps(a: __m256, b: __m256, imm8: i32) -> __m256;
#[link_name = "llvm.x86.avx.hadd.pd.256"]

View file

@ -118,7 +118,8 @@ pub unsafe fn _mm_blendv_pd(a: __m128d, b: __m128d, mask: __m128d) -> __m128d {
#[cfg_attr(test, assert_instr(blendvps))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_blendv_ps(a: __m128, b: __m128, mask: __m128) -> __m128 {
blendvps(a, b, mask)
let mask: i32x4 = simd_lt(transmute::<_, i32x4>(mask), i32x4::splat(0));
transmute(simd_select(mask, b.as_f32x4(), a.as_f32x4()))
}
/// Blend packed double-precision (64-bit) floating-point elements from `a`
@ -1138,8 +1139,6 @@ pub unsafe fn _mm_test_mix_ones_zeros(a: __m128i, mask: __m128i) -> i32 {
#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.x86.sse41.blendvps"]
fn blendvps(a: __m128, b: __m128, mask: __m128) -> __m128;
#[link_name = "llvm.x86.sse41.blendpd"]
fn blendpd(a: __m128d, b: __m128d, imm2: u8) -> __m128d;
#[link_name = "llvm.x86.sse41.blendps"]