From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd
Date: Thu, 28 Nov 2024 11:49:01 -0600 [thread overview]
Message-ID: <c76875d8-a581-46e2-a01d-da260ff0be3a@linaro.org> (raw)
In-Reply-To: <20241128104310.3452934-15-peter.maydell@linaro.org>
On 11/28/24 04:42, Peter Maydell wrote:
> +/*
> + * 3-input NaN propagation rule, for fused multiply-add. Individual
> + * architectures have different rules for which input NaN is
> + * propagated to the output when there is more than one NaN on the
> + * input.
> + *
> + * If default_nan_mode is enabled then it is valid not to set a NaN
> + * propagation rule, because the softfloat code guarantees not to try
> + * to pick a NaN to propagate in default NaN mode. When not in
> + * default-NaN mode, it is an error for the target not to set the rule
> + * in float_status if it uses a muladd, and we will assert if we need
> + * to handle an input NaN and no rule was selected.
> + *
> + * For QEMU, the multiply-add operation is A * B + C.
> + *
> + * NB: we don't list all 12 possibilities here or implement them
> + * in pickNaNMulAdd; if your architecture needs one of the missing
> + * combinations you should add it.
> + */
> +typedef enum __attribute__((__packed__)) {
> + /* No propagation rule specified */
> + float_3nan_prop_none = 0,
> + /* Prefer SNaN over QNaN, then operand A over B over C */
> + float_3nan_prop_s_abc,
> + /* Prefer SNaN over QNaN, then operand C over A over B */
> + float_3nan_prop_s_cab,
> + /* Prefer SNaN over QNaN, then operand C over B over A */
> + float_3nan_prop_s_cba,
> + /* Prefer A over B over C regardless of SNaN vs QNaN */
> + float_3nan_prop_abc,
> + /* Prefer A over C over B regardless of SNaN vs QNaN */
> + float_3nan_prop_acb,
> + /* Prefer C over B over A regardless of SNaN vs QNaN */
> + float_3nan_prop_cba,
> +} Float3NaNPropRule;
Oof. I was imagining a bit more data driven solution, rather than explicitly enumerating.
For instance:
FIELD(3NAN, 1ST, 0, 2)
FIELD(3NAN, 2ND, 2, 2)
FIELD(3NAN, 3RD, 4, 2)
FIELD(3NAN, SNAN, 6, 1)
float_3nan_prop_abc = (0 << R_3NAN_1ST_SHIFT)
| (1 << R_3NAN_2ND_SHIFT)
| (2 << R_3NAN_3RD_SHIFT),
float_3nan_prop_s_abc = float_3nan_prop_abc | R_3NAN_SNAN_MASK,
FloatClass cls[3] = { a_cls, b_cls, c_cls };
if (rule & R_3NAN_SNAN_MASK && abc_mask & float_cmask_snan) {
do {
which = rule & R_3NAN_1ST_MASK;
rule >>= R_3NAN_1ST_LENGTH;
} while (!is_snan(cls[which]));
} else {
do {
which = rule & R_3NAN_1ST_MASK;
rule >>= R_3NAN_1ST_LENGTH;
} while (!is_nan(cls[which]));
}
return which;
r~
next prev parent reply other threads:[~2024-11-28 17:50 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 10:42 [PATCH for-10.0 00/25] fpu: Make pickNaNMulAdd behaviour runtime selected Peter Maydell
2024-11-28 10:42 ` [PATCH for-10.0 01/25] fpu: handle raising Invalid for infzero in pick_nan_muladd Peter Maydell
2024-11-28 13:07 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 02/25] fpu: Check for default_nan_mode before calling pickNaNMulAdd Peter Maydell
2024-11-28 13:09 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 03/25] softfloat: Allow runtime choice of inf * 0 + NaN result Peter Maydell
2024-11-28 13:26 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 04/25] tests/fp: Explicitly set inf-zero-nan rule Peter Maydell
2024-11-28 13:26 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 05/25] target/arm: Set FloatInfZeroNaNRule explicitly Peter Maydell
2024-11-28 13:27 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 06/25] target/s390: " Peter Maydell
2024-11-28 13:28 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 07/25] target/ppc: " Peter Maydell
2024-11-28 13:28 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 08/25] target/mips: " Peter Maydell
2024-11-28 13:29 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 09/25] target/sparc: " Peter Maydell
2024-11-28 13:30 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 10/25] target/xtensa: " Peter Maydell
2024-11-28 13:30 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 11/25] target/x86: " Peter Maydell
2024-11-28 14:04 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 12/25] target/loongarch: " Peter Maydell
2024-11-28 14:09 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 13/25] target/hppa: " Peter Maydell
2024-11-28 14:10 ` Richard Henderson
2024-11-28 10:42 ` [PATCH for-10.0 14/25] softfloat: Allow runtime choice of NaN propagation for muladd Peter Maydell
2024-11-28 17:49 ` Richard Henderson [this message]
2024-11-28 10:43 ` [PATCH for-10.0 15/25] tests/fp: Explicitly set 3-NaN propagation rule Peter Maydell
2024-11-28 17:49 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 16/25] target/arm: Set Float3NaNPropRule explicitly Peter Maydell
2024-11-28 17:51 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 17/25] target/loongarch: " Peter Maydell
2024-11-28 17:52 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 18/25] target/ppc: " Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 19/25] target/s390x: " Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 20/25] target/sparc: " Peter Maydell
2024-11-28 17:53 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 21/25] target/mips: " Peter Maydell
2024-11-28 17:54 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 22/25] target/xtensa: " Peter Maydell
2024-11-28 17:55 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 23/25] target/i386: " Peter Maydell
2024-11-28 17:56 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 24/25] target/hppa: " Peter Maydell
2024-11-28 17:57 ` Richard Henderson
2024-11-28 10:43 ` [PATCH for-10.0 25/25] fpu: Remove use_first_nan field from float_status Peter Maydell
2024-11-28 17:58 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c76875d8-a581-46e2-a01d-da260ff0be3a@linaro.org \
--to=richard.henderson@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).