Implement AVX512F 64-bit shift by immediate (slli_epi64) with simd_shl instead of LLVM intrinsics
This commit is contained in:
parent
bf3a28f6ad
commit
25a978a69f
1 changed files with 44 additions and 32 deletions
|
|
@ -17387,9 +17387,11 @@ pub unsafe fn _mm_maskz_srli_epi32<const IMM8: u32>(k: __mmask8, a: __m128i) ->
|
|||
#[rustc_legacy_const_generics(1)]
|
||||
pub unsafe fn _mm512_slli_epi64<const IMM8: u32>(a: __m512i) -> __m512i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let a = a.as_i64x8();
|
||||
let r = vpslliq(a, IMM8);
|
||||
transmute(r)
|
||||
if IMM8 >= 64 {
|
||||
_mm512_setzero_si512()
|
||||
} else {
|
||||
transmute(simd_shl(a.as_u64x8(), u64x8::splat(IMM8 as u64)))
|
||||
}
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
|
||||
|
|
@ -17405,9 +17407,12 @@ pub unsafe fn _mm512_mask_slli_epi64<const IMM8: u32>(
|
|||
a: __m512i,
|
||||
) -> __m512i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let a = a.as_i64x8();
|
||||
let shf = vpslliq(a, IMM8);
|
||||
transmute(simd_select_bitmask(k, shf, src.as_i64x8()))
|
||||
let shf = if IMM8 >= 64 {
|
||||
u64x8::splat(0)
|
||||
} else {
|
||||
simd_shl(a.as_u64x8(), u64x8::splat(IMM8 as u64))
|
||||
};
|
||||
transmute(simd_select_bitmask(k, shf, src.as_u64x8()))
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set).
|
||||
|
|
@ -17419,10 +17424,13 @@ pub unsafe fn _mm512_mask_slli_epi64<const IMM8: u32>(
|
|||
#[rustc_legacy_const_generics(2)]
|
||||
pub unsafe fn _mm512_maskz_slli_epi64<const IMM8: u32>(k: __mmask8, a: __m512i) -> __m512i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let a = a.as_i64x8();
|
||||
let shf = vpslliq(a, IMM8);
|
||||
let zero = _mm512_setzero_si512().as_i64x8();
|
||||
transmute(simd_select_bitmask(k, shf, zero))
|
||||
if IMM8 >= 64 {
|
||||
_mm512_setzero_si512()
|
||||
} else {
|
||||
let shf = simd_shl(a.as_u64x8(), u64x8::splat(IMM8 as u64));
|
||||
let zero = u64x8::splat(0);
|
||||
transmute(simd_select_bitmask(k, shf, zero))
|
||||
}
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
|
||||
|
|
@ -17438,9 +17446,12 @@ pub unsafe fn _mm256_mask_slli_epi64<const IMM8: u32>(
|
|||
a: __m256i,
|
||||
) -> __m256i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let imm8 = IMM8 as i32;
|
||||
let r = pslliq256(a.as_i64x4(), imm8);
|
||||
transmute(simd_select_bitmask(k, r, src.as_i64x4()))
|
||||
let r = if IMM8 >= 64 {
|
||||
u64x4::splat(0)
|
||||
} else {
|
||||
simd_shl(a.as_u64x4(), u64x4::splat(IMM8 as u64))
|
||||
};
|
||||
transmute(simd_select_bitmask(k, r, src.as_u64x4()))
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set).
|
||||
|
|
@ -17452,10 +17463,13 @@ pub unsafe fn _mm256_mask_slli_epi64<const IMM8: u32>(
|
|||
#[rustc_legacy_const_generics(2)]
|
||||
pub unsafe fn _mm256_maskz_slli_epi64<const IMM8: u32>(k: __mmask8, a: __m256i) -> __m256i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let imm8 = IMM8 as i32;
|
||||
let r = pslliq256(a.as_i64x4(), imm8);
|
||||
let zero = _mm256_setzero_si256().as_i64x4();
|
||||
transmute(simd_select_bitmask(k, r, zero))
|
||||
if IMM8 >= 64 {
|
||||
_mm256_setzero_si256()
|
||||
} else {
|
||||
let r = simd_shl(a.as_u64x4(), u64x4::splat(IMM8 as u64));
|
||||
let zero = u64x4::splat(0);
|
||||
transmute(simd_select_bitmask(k, r, zero))
|
||||
}
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set).
|
||||
|
|
@ -17471,9 +17485,12 @@ pub unsafe fn _mm_mask_slli_epi64<const IMM8: u32>(
|
|||
a: __m128i,
|
||||
) -> __m128i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let imm8 = IMM8 as i32;
|
||||
let r = pslliq128(a.as_i64x2(), imm8);
|
||||
transmute(simd_select_bitmask(k, r, src.as_i64x2()))
|
||||
let r = if IMM8 >= 64 {
|
||||
u64x2::splat(0)
|
||||
} else {
|
||||
simd_shl(a.as_u64x2(), u64x2::splat(IMM8 as u64))
|
||||
};
|
||||
transmute(simd_select_bitmask(k, r, src.as_u64x2()))
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a left by imm8 while shifting in zeros, and store the results in dst using zeromask k (elements are zeroed out when the corresponding mask bit is not set).
|
||||
|
|
@ -17485,10 +17502,13 @@ pub unsafe fn _mm_mask_slli_epi64<const IMM8: u32>(
|
|||
#[rustc_legacy_const_generics(2)]
|
||||
pub unsafe fn _mm_maskz_slli_epi64<const IMM8: u32>(k: __mmask8, a: __m128i) -> __m128i {
|
||||
static_assert_uimm_bits!(IMM8, 8);
|
||||
let imm8 = IMM8 as i32;
|
||||
let r = pslliq128(a.as_i64x2(), imm8);
|
||||
let zero = _mm_setzero_si128().as_i64x2();
|
||||
transmute(simd_select_bitmask(k, r, zero))
|
||||
if IMM8 >= 64 {
|
||||
_mm_setzero_si128()
|
||||
} else {
|
||||
let r = simd_shl(a.as_u64x2(), u64x2::splat(IMM8 as u64));
|
||||
let zero = u64x2::splat(0);
|
||||
transmute(simd_select_bitmask(k, r, zero))
|
||||
}
|
||||
}
|
||||
|
||||
/// Shift packed 64-bit integers in a right by imm8 while shifting in zeros, and store the results in dst.
|
||||
|
|
@ -38477,14 +38497,6 @@ extern "C" {
|
|||
#[link_name = "llvm.x86.sse2.psrli.d"]
|
||||
fn psrlid128(a: i32x4, imm8: i32) -> i32x4;
|
||||
|
||||
#[link_name = "llvm.x86.avx512.pslli.q.512"]
|
||||
fn vpslliq(a: i64x8, imm8: u32) -> i64x8;
|
||||
|
||||
#[link_name = "llvm.x86.avx2.pslli.q"]
|
||||
fn pslliq256(a: i64x4, imm8: i32) -> i64x4;
|
||||
#[link_name = "llvm.x86.sse2.pslli.q"]
|
||||
fn pslliq128(a: i64x2, imm8: i32) -> i64x2;
|
||||
|
||||
#[link_name = "llvm.x86.avx512.psrli.q.512"]
|
||||
fn vpsrliq(a: i64x8, imm8: u32) -> i64x8;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue