From 95f4837fd8830f20cb193fdc7950d353c6a63984 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Fri, 24 Apr 2026 10:49:22 +0200 Subject: [PATCH] Fix VSX rounding --- include/xsimd/arch/xsimd_vsx.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/xsimd/arch/xsimd_vsx.hpp b/include/xsimd/arch/xsimd_vsx.hpp index bf4c08308..122b916c7 100644 --- a/include/xsimd/arch/xsimd_vsx.hpp +++ b/include/xsimd/arch/xsimd_vsx.hpp @@ -605,8 +605,18 @@ namespace xsimd } // round - template ::value>> - XSIMD_INLINE batch round(batch const& self, requires_arch) noexcept + + // vec_round exists also for float vectors but is mapped to vrfin instruction which uses the wrong rounding mode +#if defined __has_builtin && __has_builtin(__builtin_vsx_xvrspi) + template + XSIMD_INLINE batch round(batch const& self, requires_arch) noexcept + { + return __builtin_vsx_xvrspi(self.data); + } +#endif + // For double vectors vec_round uses xvrdpi which does the right thing + template + XSIMD_INLINE batch round(batch const& self, requires_arch) noexcept { return vec_round(self.data); }