Skip to content

Commit

Permalink
Add support for _mm_srli_epi64
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Piolat committed Aug 13, 2024
1 parent 6f50351 commit 37fb9aa
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion source/inteli/avx2intrin.d
Original file line number Diff line number Diff line change
Expand Up @@ -3606,7 +3606,37 @@ unittest
assert(C.array == expectedC);
}

// TODO __m256i _mm256_srli_epi64 (__m256i a, int imm8) pure @safe
/// Shift packed 64-bit integers in `a` right by `imm8` while shifting in zeros.
__m256i _mm256_srli_epi64 (__m256i a, int imm8) pure @safe
{
static if (GDC_or_LDC_with_AVX2)
{
return cast(__m256i) __builtin_ia32_psrlqi256(cast(int8)a, cast(ubyte)imm8);
}
else
{
// split
__m128i a_lo = _mm256_extractf128_si256!0(a);
__m128i a_hi = _mm256_extractf128_si256!1(a);
__m128i r_lo = _mm_srli_epi64(a_lo, imm8);
__m128i r_hi = _mm_srli_epi64(a_hi, imm8);
return _mm256_set_m128i(r_hi, r_lo);
}
}
unittest
{
__m256i A = _mm256_setr_epi64(8, -4, 16, -8);
long4 B = cast(long4) _mm256_srli_epi64(A, 1);
long4 B2 = cast(long4) _mm256_srli_epi64(A, 1 + 512);
long[4] expectedB = [ 4, 0x7FFFFFFFFFFFFFFE, 8, 0x7FFFFFFFFFFFFFFC];
assert(B.array == expectedB);
assert(B2.array == expectedB);

long4 C = cast(long4) _mm256_srli_epi64(A, 64);
long[4] expectedC = [ 0, 0, 0, 0 ];
assert(C.array == expectedC);
}

// TODO __m256i _mm256_srli_si256 (__m256i a, const int imm8) pure @safe
// TODO __m128i _mm_srlv_epi32 (__m128i a, __m128i count) pure @safe
// TODO __m256i _mm256_srlv_epi32 (__m256i a, __m256i count) pure @safe
Expand Down

0 comments on commit 37fb9aa

Please sign in to comment.