From 854b79287818a01137aa78e59e36ab10240bf13b Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 9 Jan 2021 12:49:38 -0500 Subject: Add compile-time AVX512VL versions of Ch and Maj for AVX2 Tested with Intel SDE --- src/lib/utils/simd/simd_avx2/simd_avx2.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib/utils/simd') diff --git a/src/lib/utils/simd/simd_avx2/simd_avx2.h b/src/lib/utils/simd/simd_avx2/simd_avx2.h index 37deb87be..566dfd0a8 100644 --- a/src/lib/utils/simd/simd_avx2/simd_avx2.h +++ b/src/lib/utils/simd/simd_avx2/simd_avx2.h @@ -270,13 +270,21 @@ class SIMD_8x32 final BOTAN_FUNC_ISA("avx2") static SIMD_8x32 choose(const SIMD_8x32& mask, const SIMD_8x32& a, const SIMD_8x32& b) { +#if defined(__AVX512VL__) + return _mm256_ternarylogic_epi32(mask.handle(), a.handle(), b.handle(), 0xca); +#else return (mask & a) ^ mask.andc(b); +#endif } BOTAN_FUNC_ISA("avx2") static SIMD_8x32 majority(const SIMD_8x32& x, const SIMD_8x32& y, const SIMD_8x32& z) { +#if defined(__AVX512VL__) + return _mm256_ternarylogic_epi32(x.handle(), y.handle(), z.handle(), 0xe8); +#else return SIMD_8x32::choose(x ^ y, z, y); +#endif } BOTAN_FUNC_ISA("avx2") -- cgit v1.2.3