Skip to content

Commit 6940fc1

Browse files
Prevent some invalid associativity in to_float implementation for avx2 under -ffast-math
Fix #1264
1 parent 548b05f commit 6940fc1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/xsimd/arch/xsimd_avx2.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ namespace xsimd
542542
__m256i mask = _mm256_setr_epi16(0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000,
543543
0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000);
544544
__m256i xL = _mm256_or_si256(_mm256_and_si256(mask, x), _mm256_andnot_si256(mask, _mm256_castpd_si256(_mm256_set1_pd(0x0010000000000000)))); // 2^52
545+
#ifdef __FAST_MATH__
546+
volatile // prevents some association with the add below, when converting from (-1, -1, 0, 0)
547+
#endif
545548
__m256d f = _mm256_sub_pd(_mm256_castsi256_pd(xH), _mm256_set1_pd(442726361368656609280.)); // 3*2^67 + 2^52
546549
return _mm256_add_pd(f, _mm256_castsi256_pd(xL));
547550
}

0 commit comments

Comments
 (0)