From 0726d91d70e4fb3f011b5642d016559268e7f66a Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Wed, 20 Aug 2025 20:58:11 +0200 Subject: [PATCH] Generate a swizzle-friendly mask during generic reduction It changes nothing for clang which has a nice shuffle optimizer, but it does help gcc a lot. Somehow related to #1132 --- include/xsimd/arch/common/xsimd_common_math.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xsimd/arch/common/xsimd_common_math.hpp b/include/xsimd/arch/common/xsimd_common_math.hpp index cdd35c5dd..10db980e2 100644 --- a/include/xsimd/arch/common/xsimd_common_math.hpp +++ b/include/xsimd/arch/common/xsimd_common_math.hpp @@ -2110,7 +2110,7 @@ namespace xsimd { static constexpr T get(T i, T) { - return i >= N ? (i % 2) : i + N; + return i < N ? (i + N) : ((i % N) + N); } };