From 66e950d2e90c29f826f0ad2c842861c4b6ab4b42 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 2 Sep 2021 07:37:18 +0200 Subject: [PATCH] Prevent reordering of some floating point op under fast-math --- include/xsimd/arch/generic/xsimd_generic_math.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/xsimd/arch/generic/xsimd_generic_math.hpp b/include/xsimd/arch/generic/xsimd_generic_math.hpp index 87e9626c5..0e477f2a4 100644 --- a/include/xsimd/arch/generic/xsimd_generic_math.hpp +++ b/include/xsimd/arch/generic/xsimd_generic_math.hpp @@ -1733,8 +1733,8 @@ namespace xsimd { // to v. That's not what we want, so prevent compiler optimization here. // FIXME: it may be better to emit a memory barrier here (?). #ifdef __FAST_MATH__ - volatile batch_type d0 = v + t2n; - batch_type d = *(batch_type*)(void*)(&d0) - t2n; + volatile auto d0 = (v + t2n).data; + batch_type d = batch_type(d0) - t2n; #else batch_type d0 = v + t2n; batch_type d = d0 - t2n;