From 82324d3993aa40ac7a24db6b2d40d7edf129276e Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 10 Nov 2018 13:42:31 -0500 Subject: Use vzeroupper/vzeroall to transition between AVX and SSE states. Otherwise some CPUs suffer serious stalls. Using vzeroall on exit also has the nice effect that we don't have to worry about register contents leaking. HT to @noloader for doing the background research on this. --- src/lib/utils/simd/simd_avx2/simd_avx2.h | 12 ++++++++++++ 1 file changed, 12 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 6e8c04f4b..fde086e53 100644 --- a/src/lib/utils/simd/simd_avx2/simd_avx2.h +++ b/src/lib/utils/simd/simd_avx2/simd_avx2.h @@ -227,6 +227,18 @@ class SIMD_8x32 final B3.m_avx2 = _mm256_unpackhi_epi64(T2, T3); } + BOTAN_FUNC_ISA("avx2") + static void reset_registers() + { + _mm256_zeroupper(); + } + + BOTAN_FUNC_ISA("avx2") + static void zero_registers() + { + _mm256_zeroall(); + } + __m256i handle() const { return m_avx2; } private: -- cgit v1.2.3