From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25089 invoked by alias); 19 Mar 2018 20:10:24 -0000 Mailing-List: contact libc-stable-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: List-Archive: Sender: libc-stable-owner@sourceware.org Received: (qmail 25061 invoked by uid 89); 19 Mar 2018 20:10:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,T_RP_MATCHES_RCVD,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-23.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,T_RP_MATCHES_RCVD,UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: hall.aurel32.net Received: from hall.aurel32.net (HELO hall.aurel32.net) (163.172.24.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Mar 2018 20:10:22 +0000 Received: from [2001:bc8:30d7:120:9bb5:8936:7e6a:9e36] (helo=ohm.rr44.fr) by hall.aurel32.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ey16q-0006nE-8R; Mon, 19 Mar 2018 21:10:20 +0100 Received: from aurel32 by ohm.rr44.fr with local (Exim 4.90_1) (envelope-from ) id 1ey16p-0007fR-L2; Mon, 19 Mar 2018 21:10:19 +0100 From: Aurelien Jarno To: libc-stable@sourceware.org Cc: Andrew Waterman Subject: [2.27 COMMITTED 2/3] RISC-V: fmax/fmin: Handle signalling NaNs correctly. Date: Mon, 01 Jan 2018 00:00:00 -0000 Message-Id: <20180319201013.29404-2-aurelien@aurel32.net> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180319201013.29404-1-aurelien@aurel32.net> References: <20180319201013.29404-1-aurelien@aurel32.net> X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00035.txt.bz2 From: Andrew Waterman RISC-V's fmax(sNAN,4) returns 4 but glibc expects it to return qNAN. * sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly. * sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise. * sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise. * sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise. (cherry picked from commit fdcc625376505eacb1125a6aeba57501407a30ec) --- ChangeLog | 7 +++++++ sysdeps/riscv/rvd/s_fmax.c | 11 +++++++++-- sysdeps/riscv/rvd/s_fmin.c | 11 +++++++++-- sysdeps/riscv/rvf/s_fmaxf.c | 11 +++++++++-- sysdeps/riscv/rvf/s_fminf.c | 11 +++++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b859f637d6..394f6703638 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-02-22 Andrew Waterman + + * sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly. + * sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise. + * sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise. + * sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise. + 2018-02-22 DJ Delorie * sysdeps/riscv/tls-macros.h: Do not initialize $gp. diff --git a/sysdeps/riscv/rvd/s_fmax.c b/sysdeps/riscv/rvd/s_fmax.c index ef8f1344ce5..22e91bfc4b8 100644 --- a/sysdeps/riscv/rvd/s_fmax.c +++ b/sysdeps/riscv/rvd/s_fmax.c @@ -17,12 +17,19 @@ . */ #include +#include #include double __fmax (double x, double y) { - asm ("fmax.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); - return x; + double res; + + if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) + return x + y; + else + asm ("fmax.d %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); + + return res; } libm_alias_double (__fmax, fmax) diff --git a/sysdeps/riscv/rvd/s_fmin.c b/sysdeps/riscv/rvd/s_fmin.c index c6ff24cefb8..7b35230cacd 100644 --- a/sysdeps/riscv/rvd/s_fmin.c +++ b/sysdeps/riscv/rvd/s_fmin.c @@ -17,12 +17,19 @@ . */ #include +#include #include double __fmin (double x, double y) { - asm ("fmin.d %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); - return x; + double res; + + if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) + return x + y; + else + asm ("fmin.d %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); + + return res; } libm_alias_double (__fmin, fmin) diff --git a/sysdeps/riscv/rvf/s_fmaxf.c b/sysdeps/riscv/rvf/s_fmaxf.c index 3293f2f41ca..63f7e3d6648 100644 --- a/sysdeps/riscv/rvf/s_fmaxf.c +++ b/sysdeps/riscv/rvf/s_fmaxf.c @@ -17,12 +17,19 @@ . */ #include +#include #include float __fmaxf (float x, float y) { - asm ("fmax.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); - return x; + float res; + + if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) + return x + y; + else + asm ("fmax.s %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); + + return res; } libm_alias_float (__fmax, fmax) diff --git a/sysdeps/riscv/rvf/s_fminf.c b/sysdeps/riscv/rvf/s_fminf.c index e4411f04b25..82cca4e37d8 100644 --- a/sysdeps/riscv/rvf/s_fminf.c +++ b/sysdeps/riscv/rvf/s_fminf.c @@ -17,12 +17,19 @@ . */ #include +#include #include float __fminf (float x, float y) { - asm ("fmin.s %0, %1, %2" : "=f" (x) : "f" (x), "f" (y)); - return x; + float res; + + if (__glibc_unlikely ((_FCLASS (x) | _FCLASS (y)) & _FCLASS_SNAN)) + return x + y; + else + asm ("fmin.s %0, %1, %2" : "=f" (res) : "f" (x), "f" (y)); + + return res; } libm_alias_float (__fmin, fmin) -- 2.16.1