Re: [PATCH v3 03/11] fpu: Hoist nan check in partsN_addsub

2026-05-14 Thread Philippe Mathieu-Daudé

On 7/5/26 18:09, Richard Henderson wrote:

The nan test had been down below because it was unlikely.
But if we have to have one anyway because of denormals,
we might as well take care of them right away.

Signed-off-by: Richard Henderson 
---
  fpu/softfloat-parts.c.inc | 19 +--
  1 file changed, 5 insertions(+), 14 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé 



[PATCH v3 03/11] fpu: Hoist nan check in partsN_addsub

2026-05-07 Thread Richard Henderson
The nan test had been down below because it was unlikely.
But if we have to have one anyway because of denormals,
we might as well take care of them right away.

Signed-off-by: Richard Henderson 
---
 fpu/softfloat-parts.c.inc | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 87525fb4b6..20cb739c75 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -530,13 +530,15 @@ FloatPartsN partsN(addsub)(const FloatPartsN *a_orig,
 {
 int ab_mask = float_cmask(a_orig->cls) | float_cmask(b_orig->cls);
 
+if (unlikely(ab_mask & float_cmask_anynan)) {
+return partsN(pick_nan)(a_orig, b_orig, s);
+}
+
 /*
  * For addition and subtraction, we will consume an
  * input denormal unless the other input is a NaN.
  */
-if (!(ab_mask & float_cmask_anynan)) {
-record_denormals_used(ab_mask, s);
-}
+record_denormals_used(ab_mask, s);
 
 FloatPartsN a = *a_orig;
 FloatPartsN b = *b_orig;
@@ -558,10 +560,6 @@ FloatPartsN partsN(addsub)(const FloatPartsN *a_orig,
 return a;
 }
 
-if (unlikely(ab_mask & float_cmask_anynan)) {
-goto p_nan;
-}
-
 if (ab_mask & float_cmask_inf) {
 if (a.cls != float_class_inf) {
 /* N - Inf */
@@ -586,10 +584,6 @@ FloatPartsN partsN(addsub)(const FloatPartsN *a_orig,
 return a;
 }
 
-if (unlikely(ab_mask & float_cmask_anynan)) {
-goto p_nan;
-}
-
 if (ab_mask & float_cmask_inf) {
 a.cls = float_class_inf;
 return a;
@@ -604,9 +598,6 @@ FloatPartsN partsN(addsub)(const FloatPartsN *a_orig,
 g_assert(a.cls == float_class_zero);
 g_assert(is_anynorm(b.cls));
 return b;
-
- p_nan:
-return partsN(pick_nan)(a_orig, b_orig, s);
 }
 
 /*
-- 
2.43.0