softfloat: Replace WHICH with RET in parts_pick_nan

Replace the "index" selecting between A and B with a result variable
of the proper type.  This improves clarity within the function.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20241203203949.483774-12-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2024-12-11 15:31:09 +00:00 committed by Peter Maydell
parent 9778115ed7
commit cc87d3d381

View file

@ -40,7 +40,8 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
float_status *s) float_status *s)
{ {
bool have_snan = false; bool have_snan = false;
int cmp, which; FloatPartsN *ret;
int cmp;
if (is_snan(a->cls) || is_snan(b->cls)) { if (is_snan(a->cls) || is_snan(b->cls)) {
float_raise(float_flag_invalid | float_flag_invalid_snan, s); float_raise(float_flag_invalid | float_flag_invalid_snan, s);
@ -55,21 +56,21 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
switch (s->float_2nan_prop_rule) { switch (s->float_2nan_prop_rule) {
case float_2nan_prop_s_ab: case float_2nan_prop_s_ab:
if (have_snan) { if (have_snan) {
which = is_snan(a->cls) ? 0 : 1; ret = is_snan(a->cls) ? a : b;
break; break;
} }
/* fall through */ /* fall through */
case float_2nan_prop_ab: case float_2nan_prop_ab:
which = is_nan(a->cls) ? 0 : 1; ret = is_nan(a->cls) ? a : b;
break; break;
case float_2nan_prop_s_ba: case float_2nan_prop_s_ba:
if (have_snan) { if (have_snan) {
which = is_snan(b->cls) ? 1 : 0; ret = is_snan(b->cls) ? b : a;
break; break;
} }
/* fall through */ /* fall through */
case float_2nan_prop_ba: case float_2nan_prop_ba:
which = is_nan(b->cls) ? 1 : 0; ret = is_nan(b->cls) ? b : a;
break; break;
case float_2nan_prop_x87: case float_2nan_prop_x87:
/* /*
@ -85,35 +86,32 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
*/ */
if (is_snan(a->cls)) { if (is_snan(a->cls)) {
if (!is_snan(b->cls)) { if (!is_snan(b->cls)) {
which = is_qnan(b->cls) ? 1 : 0; ret = is_qnan(b->cls) ? b : a;
break; break;
} }
} else if (is_qnan(a->cls)) { } else if (is_qnan(a->cls)) {
if (is_snan(b->cls) || !is_qnan(b->cls)) { if (is_snan(b->cls) || !is_qnan(b->cls)) {
which = 0; ret = a;
break; break;
} }
} else { } else {
which = 1; ret = b;
break; break;
} }
cmp = frac_cmp(a, b); cmp = frac_cmp(a, b);
if (cmp == 0) { if (cmp == 0) {
cmp = a->sign < b->sign; cmp = a->sign < b->sign;
} }
which = cmp > 0 ? 0 : 1; ret = cmp > 0 ? a : b;
break; break;
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }
if (which) { if (is_snan(ret->cls)) {
a = b; parts_silence_nan(ret, s);
} }
if (is_snan(a->cls)) { return ret;
parts_silence_nan(a, s);
}
return a;
} }
static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,