Skip to contentSkip to conversation

fpu: Handle all rounding modes in softfloat-parts.c.inc

PATCH In review Richard Henderson 3 participants 9 messages Jun 8 – Jun 10

lore
Share & tools
lore
#0 lore raw

cover fpu: Handle all rounding modes in softfloat-parts.c.inc

Fix up some unusual rounding modes.

r~

Richard Henderson (2):
fpu: Handle all rounding modes in partsN_uncanon_normal
fpu: Handle all rounding modes in partsN_round_to_int_normal

 fpu/softfloat-parts.c.inc | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 fpu: Handle all rounding modes in partsN_uncanon_normal

Missed float_round_nearest_even_max when recomputing round.

---
 fpu/softfloat-parts.c.inc | 1 +
 1 file changed, 1 insertion(+)
fpu/softfloat-parts.c.inc +1 -0
index a154faf32b..c86fc9ccc5 100644
@@ -437,6 +437,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
             /* Need to recompute round-to-even/round-to-odd. */
             switch (get_float_rounding_mode(s)) {
             case float_round_nearest_even:
+            case float_round_nearest_even_max:
                 if (N > 64 && frac_lsb == 0) {
                     inc = ((p->frac_hi & 1) ||
                            (p->frac_lo & round_mask) != frac_lsbm1
Signature · 1 line
2.43.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] fpu: Handle all rounding modes in partsN_uncanon_normal

Quoted 8 lines · Richard Henderson

Missed float_round_nearest_even_max when recomputing round.

---
 fpu/softfloat-parts.c.inc | 1 +
 1 file changed, 1 insertion(+)
Fixes 72330260cdb ("softfloat: Add float_round_nearest_even_max")

(dunno if hexagon hits this codepath, but it doesn't hurt to put the fix into stable)

thanks
-- PMM

#3 lore raw

Re: [PATCH 1/2] fpu: Handle all rounding modes in partsN_uncanon_normal

Quoted 5 lines · Peter Maydell
Quoted 3 lines · Richard Henderson

Missed float_round_nearest_even_max when recomputing round.

Quoted 8 lines
Quoted 5 lines
---
  fpu/softfloat-parts.c.inc | 1 +
  1 file changed, 1 insertion(+)
Fixes 72330260cdb ("softfloat: Add float_round_nearest_even_max")
Quoted 9 lines

(dunno if hexagon hits this codepath, but it doesn't hurt to put the fix into stable)

thanks
-- PMM

#4 lore raw

PATCH 2/2 fpu: Handle all rounding modes in partsN_round_to_int_normal

In reply to Richard Henderson

Missed float_round_nearest_even_max and float_round_to_odd_inf in both switch statements.

---
 fpu/softfloat-parts.c.inc | 4 ++++
 1 file changed, 4 insertions(+)
fpu/softfloat-parts.c.inc +4 -0
index c86fc9ccc5..deb712e092 100644
@@ -1127,6 +1127,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *a, FloatRoundMode rmode,
         /* All fractional */
         switch (rmode) {
         case float_round_nearest_even:
+        case float_round_nearest_even_max:
             one = false;
             if (a->exp == -1) {
                 FloatPartsN tmp;
@@ -1149,6 +1150,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *a, FloatRoundMode rmode,
             one = a->sign;
             break;
         case float_round_to_odd:
+        case float_round_to_odd_inf:
             one = true;
             break;
         default:
@@ -1195,6 +1197,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *a, FloatRoundMode rmode,
 
     switch (rmode) {
     case float_round_nearest_even:
+    case float_round_nearest_even_max:
         inc = ((a->frac_lo & rnd_even_mask) != frac_lsbm1 ? frac_lsbm1 : 0);
         break;
     case float_round_ties_away:
@@ -1210,6 +1213,7 @@ static bool partsN(round_to_int_normal)(FloatPartsN *a, FloatRoundMode rmode,
         inc = a->sign ? rnd_mask : 0;
         break;
     case float_round_to_odd:
+    case float_round_to_odd_inf:
         inc = a->frac_lo & frac_lsb ? 0 : rnd_mask;
         break;
     default:
Signature · 1 line
2.43.0
#7 lore raw
In reply to Richard Henderson
Quoted 11 lines · Richard Henderson

Fix up some unusual rounding modes.

r~

Richard Henderson (2):
fpu: Handle all rounding modes in partsN_uncanon_normal
fpu: Handle all rounding modes in partsN_round_to_int_normal

 fpu/softfloat-parts.c.inc | 5 +++++
 1 file changed, 5 insertions(+)

roundAndPackFloatx80() is the other function that doesn't implement all the rounding modes. But I guess we can assume that 80-bit floats are not going to ever need them. (It will assert if called with anything other than nearest_even, ties_away, to_zero, round_up or round_down, so we'll easily spot the cause if we ever need the functionality.)

thanks
-- PMM

#8 lore raw
In reply to Richard Henderson
Quoted 9 lines · Richard Henderson

Fix up some unusual rounding modes.

r~

Richard Henderson (2):
fpu: Handle all rounding modes in partsN_uncanon_normal
fpu: Handle all rounding modes in partsN_round_to_int_normal

I'm going to apply this to target-arm.next since it's a prerequisite for the FEAT_FP8 series.

thanks
-- PMM