Skip to content

Commit 88bc619

Browse files
committed
Fix issue #215 (internal compiler error)
Visual Studio 2017 produces an internal compiler error in _release_ mode for the function call _mm512_broadcast_i32x4(_mm_set_epi64x(a, b)). Affected are the AEGIS algorithms aegis-128x4 and aegis-256x4. The AVX512 instruction _mm512_broadcast_i32x4 is replaced by simpler, but otherwise equivalent instructions, which do not confuse the VS2017 optimizer.
1 parent 7ac36a9 commit 88bc619

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/aegis/aegis128x4/aegis128x4_avx512.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,20 @@ AEGIS_AES_BLOCK_LOAD(const uint8_t *a)
6767
static inline AEGIS_AES_BLOCK_T
6868
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6969
{
70+
#if defined(_MSC_VER) && (_MSC_VER >= 1910 && _MSC_VER < 1920)
71+
/*
72+
** Visual Studio 2017 produces an internal compiler error in release mode
73+
** for the function call _mm512_broadcast_i32x4(_mm_set_epi64x(a, b)).
74+
** Therefore perform the operation "manually".
75+
*/
76+
__m128i x128 = _mm_set_epi64x(a, b);
77+
__m256i x256 = _mm256_broadcastsi128_si256(x128);
78+
__m512i x512 = _mm512_castsi256_si512(x256);
79+
x512 = _mm512_inserti64x4(x512, x256, 1);
80+
return x512;
81+
#else
7082
return _mm512_broadcast_i32x4(_mm_set_epi64x(a, b));
83+
#endif
7184
}
7285

7386
static inline void

src/aegis/aegis256x4/aegis256x4_avx512.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,20 @@ AEGIS_AES_BLOCK_LOAD(const uint8_t *a)
6767
static inline AEGIS_AES_BLOCK_T
6868
AEGIS_AES_BLOCK_LOAD_64x2(uint64_t a, uint64_t b)
6969
{
70+
#if defined(_MSC_VER) && (_MSC_VER >= 1910 && _MSC_VER < 1920)
71+
/*
72+
** Visual Studio 2017 produces an internal compiler error in release mode
73+
** for the function call _mm512_broadcast_i32x4(_mm_set_epi64x(a, b)).
74+
** Therefore perform the operation "manually".
75+
*/
76+
__m128i x128 = _mm_set_epi64x(a, b);
77+
__m256i x256 = _mm256_broadcastsi128_si256(x128);
78+
__m512i x512 = _mm512_castsi256_si512(x256);
79+
x512 = _mm512_inserti64x4(x512, x256, 1);
80+
return x512;
81+
#else
7082
return _mm512_broadcast_i32x4(_mm_set_epi64x(a, b));
83+
#endif
7184
}
7285

7386
static inline void

0 commit comments

Comments
 (0)