Skip to contentSkip to conversation

Hexagon (target/hexagon) properly handle NaN in dfmin/dfmax/sfmin/sfmax

PATCH In review Taylor Simpson 2 participants 2 messages Mar 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Hexagon (target/hexagon) properly handle NaN in dfmin/dfmax/sfmin/sfmax

The float??_minnum implementation differs from Hexagon for SNaN, it returns NaN, but Hexagon returns the other input. So, we use float??_minimum_number.

Test cases added to tests/tcg/hexagon/fpstuff.c

---
 target/hexagon/op_helper.c  | 14 ++-----
 tests/tcg/hexagon/fpstuff.c | 79 +++++++++++++++++++++++++++++--------
 2 files changed, 66 insertions(+), 27 deletions(-)
target/hexagon/op_helper.c +4 -10
index 057baf9a48..33a86be7be 100644
@@ -948,7 +948,7 @@ float32 HELPER(sfmax)(CPUHexagonState *env, float32 RsV, float32 RtV)
 {
     float32 RdV;
     arch_fpop_start(env);
-    RdV = float32_maxnum(RsV, RtV, &env->fp_status);
+    RdV = float32_maximum_number(RsV, RtV, &env->fp_status);
     arch_fpop_end(env);
     return RdV;
 }
@@ -957,7 +957,7 @@ float32 HELPER(sfmin)(CPUHexagonState *env, float32 RsV, float32 RtV)
 {
     float32 RdV;
     arch_fpop_start(env);
-    RdV = float32_minnum(RsV, RtV, &env->fp_status);
+    RdV = float32_minimum_number(RsV, RtV, &env->fp_status);
     arch_fpop_end(env);
     return RdV;
 }
@@ -1041,10 +1041,7 @@ float64 HELPER(dfmax)(CPUHexagonState *env, float64 RssV, float64 RttV)
 {
     float64 RddV;
     arch_fpop_start(env);
-    RddV = float64_maxnum(RssV, RttV, &env->fp_status);
-    if (float64_is_any_nan(RssV) || float64_is_any_nan(RttV)) {
-        float_raise(float_flag_invalid, &env->fp_status);
-    }
+    RddV = float64_maximum_number(RssV, RttV, &env->fp_status);
     arch_fpop_end(env);
     return RddV;
 }
@@ -1053,10 +1050,7 @@ float64 HELPER(dfmin)(CPUHexagonState *env, float64 RssV, float64 RttV)
 {
     float64 RddV;
     arch_fpop_start(env);
-    RddV = float64_minnum(RssV, RttV, &env->fp_status);
-    if (float64_is_any_nan(RssV) || float64_is_any_nan(RttV)) {
-        float_raise(float_flag_invalid, &env->fp_status);
-    }
+    RddV = float64_minimum_number(RssV, RttV, &env->fp_status);
     arch_fpop_end(env);
     return RddV;
 }
tests/tcg/hexagon/fpstuff.c +62 -17

183 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on v4 1/1
#1 lore raw
Quoted 11 lines · Taylor Simpson

The float??_minnum implementation differs from Hexagon for SNaN, it returns NaN, but Hexagon returns the other input. So, we use float??_minimum_number.

Test cases added to tests/tcg/hexagon/fpstuff.c

---
  target/hexagon/op_helper.c  | 14 ++-----
  tests/tcg/hexagon/fpstuff.c | 79 +++++++++++++++++++++++++++++--------
  2 files changed, 66 insertions(+), 27 deletions(-)

r~