@samitouri / QOSamiQemu / commits / 773911cd0e

fpu: Introduce frac_msb_is_snan

Unify handling of the two snan parameters, letting the caller simply extract the msb. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Richard Henderson committed May 8, 2026 at 16:15 UTC 773911cd0edece8e38db8423a0fe8cd790849165
1 file changed +13 -32
fpu/softfloat-specialize.c.inc
+13 -32
@@ -104,16 +104,21 @@ static inline bool snan_bit_is_one(float_status *status)
104 | if the fraction represents a signalling NaN; otherwise false.
105 *----------------------------------------------------------------------------*/
106
107 -static bool parts_is_snan_frac(uint64_t frac, float_status *status)
107 +static bool frac_msb_is_snan(bool msb, float_status *status)
108 {
109 if (no_signaling_nans(status)) {
110 return false;
111 } else {
112 - bool msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1);
112 return msb == snan_bit_is_one(status);
113 }
114 }
115
116 +static bool parts_is_snan_frac(uint64_t frac, float_status *status)
117 +{
118 + bool msb = extract64(frac, DECOMPOSED_BINARY_POINT - 1, 1);
119 + return frac_msb_is_snan(msb, status);
120 +}
121 +
122 /*----------------------------------------------------------------------------
123 | The pattern for a default generated deconstructed floating-point NaN.
124 *----------------------------------------------------------------------------*/
@@ -238,11 +243,7 @@ floatx80 floatx80_default_inf(bool zSign, float_status *status)
243
244 static bool float16_nan_is_snan(float16 a, float_status *status)
245 {
241 - if (no_signaling_nans(status)) {
242 - return false;
243 - }
244 - bool frac_msb_is_one = (a >> 9) & 1;
245 - return frac_msb_is_one == snan_bit_is_one(status);
246 + return frac_msb_is_snan((a >> 9) & 1, status);
247 }
248
249 /*----------------------------------------------------------------------------
@@ -271,11 +272,7 @@ bool float16_is_signaling_nan(float16 a_, float_status *status)
272
273 static bool bfloat16_nan_is_snan(bfloat16 a, float_status *status)
274 {
274 - if (no_signaling_nans(status)) {
275 - return false;
276 - }
277 - bool frac_msb_is_one = (a >> 6) & 1;
278 - return frac_msb_is_one == snan_bit_is_one(status);
275 + return frac_msb_is_snan((a >> 6) & 1, status);
276 }
277
278 /*----------------------------------------------------------------------------
@@ -302,11 +299,7 @@ bool bfloat16_is_signaling_nan(bfloat16 a_, float_status *status)
299
300 static bool float32_nan_is_snan(float32 a, float_status *status)
301 {
305 - if (no_signaling_nans(status)) {
306 - return false;
307 - }
308 - bool frac_msb_is_one = (a >> 22) & 1;
309 - return frac_msb_is_one == snan_bit_is_one(status);
302 + return frac_msb_is_snan((a >> 22) & 1, status);
303 }
304
305 /*----------------------------------------------------------------------------
@@ -335,11 +328,7 @@ bool float32_is_signaling_nan(float32 a_, float_status *status)
328
329 static bool float64_nan_is_snan(float64 a, float_status *status)
330 {
338 - if (no_signaling_nans(status)) {
339 - return false;
340 - }
341 - bool frac_msb_is_one = (a >> 51) & 1;
342 - return frac_msb_is_one == snan_bit_is_one(status);
331 + return frac_msb_is_snan((a >> 51) & 1, status);
332 }
333
334 /*----------------------------------------------------------------------------
@@ -370,11 +359,7 @@ bool float64_is_signaling_nan(float64 a_, float_status *status)
359
360 static bool floatx80_nan_is_snan(floatx80 a, float_status *status)
361 {
373 - if (no_signaling_nans(status)) {
374 - return false;
375 - }
376 - bool frac_msb_is_one = (a.low >> 62) & 1;
377 - return frac_msb_is_one == snan_bit_is_one(status);
362 + return frac_msb_is_snan((a.low >> 62) & 1, status);
363 }
364
365 /*----------------------------------------------------------------------------
@@ -416,11 +401,7 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status)
401
402 static bool float128_nan_is_snan(float128 a, float_status *status)
403 {
419 - if (no_signaling_nans(status)) {
420 - return false;
421 - }
422 - bool frac_msb_is_one = (a.high >> 47) & 1;
423 - return frac_msb_is_one == snan_bit_is_one(status);
404 + return frac_msb_is_snan((a.high >> 47) & 1, status);
405 }
406
407 /*----------------------------------------------------------------------------