aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/riscv/rvf
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/riscv/rvf')
-rw-r--r--sysdeps/riscv/rvf/s_fmaxf.c11
-rw-r--r--sysdeps/riscv/rvf/s_fminf.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/sysdeps/riscv/rvf/s_fmaxf.c b/sysdeps/riscv/rvf/s_fmaxf.c
index 3293f2f..63f7e3d 100644
--- a/sysdeps/riscv/rvf/s_fmaxf.c
+++ b/sysdeps/riscv/rvf/s_fmaxf.c
@@ -17,12 +17,19 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
+#include <math_private.h>
#include <libm-alias-float.h>
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 e4411f0..82cca4e 100644
--- a/sysdeps/riscv/rvf/s_fminf.c
+++ b/sysdeps/riscv/rvf/s_fminf.c
@@ -17,12 +17,19 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
+#include <math_private.h>
#include <libm-alias-float.h>
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)