aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/simd
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2021-01-09 12:49:38 -0500
committerJack Lloyd <[email protected]>2021-01-09 12:49:50 -0500
commit854b79287818a01137aa78e59e36ab10240bf13b (patch)
treee5abd052d9f3c746956feb49b01ae97ff0425502 /src/lib/utils/simd
parentc297b51694e4a9eeccb2caf8f7f65ece69128bc1 (diff)
Add compile-time AVX512VL versions of Ch and Maj for AVX2
Tested with Intel SDE
Diffstat (limited to 'src/lib/utils/simd')
-rw-r--r--src/lib/utils/simd/simd_avx2/simd_avx2.h8
1 files changed, 8 insertions, 0 deletions
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")