summaryrefslogtreecommitdiff
path: root/sysdeps/riscv/rvd/s_fmax.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/riscv/rvd/s_fmax.c')
-rw-r--r--sysdeps/riscv/rvd/s_fmax.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sysdeps/riscv/rvd/s_fmax.c b/sysdeps/riscv/rvd/s_fmax.c
index ef8f1344ce..22e91bfc4b 100644
--- a/sysdeps/riscv/rvd/s_fmax.c
+++ b/sysdeps/riscv/rvd/s_fmax.c
@@ -17,12 +17,19 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
+#include <math_private.h>
#include <libm-alias-double.h>
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)