[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/17] softfloat: Add float_muladd_suppress_add_product_zero
From: |
Richard Henderson |
Subject: |
[PATCH 06/17] softfloat: Add float_muladd_suppress_add_product_zero |
Date: |
Sun, 8 Dec 2024 16:48:33 -0600 |
Certain Hexagon instructions suppress changes to the result
when the product of fma() is a true zero.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/fpu/softfloat.h | 5 +++++
fpu/softfloat-parts.c.inc | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index aa69aecfb0..09a40b4310 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -120,11 +120,16 @@ bfloat16 bfloat16_squash_input_denormal(bfloat16 a,
float_status *status);
| Using these differs from negating an input or output before calling
| the muladd function in that this means that a NaN doesn't have its
| sign bit inverted before it is propagated.
+|
+| With float_muladd_suppress_add_product_zero, if A or B is zero
+| such that the product is a true zero, then return C without addition.
+| This preserves the sign of C when C is +/- 0. Used for Hexagon.
*----------------------------------------------------------------------------*/
enum {
float_muladd_negate_c = 1,
float_muladd_negate_product = 2,
float_muladd_negate_result = 4,
+ float_muladd_suppress_add_product_zero = 8,
};
/*----------------------------------------------------------------------------
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 2b6adeef4c..015b272e30 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -529,7 +529,9 @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a,
FloatPartsN *b,
goto return_normal;
}
if (c->cls == float_class_zero) {
- if (a->sign != c->sign) {
+ if (flags & float_muladd_suppress_add_product_zero) {
+ a->sign = c->sign;
+ } else if (a->sign != c->sign) {
goto return_sub_zero;
}
goto return_zero;
--
2.43.0
- Re: [PATCH 01/17] softfloat: Add float{16,32,64}_muladd_scalbn, (continued)
- [PATCH 02/17] target/arm: Use float*_muladd_scalbn, Richard Henderson, 2024/12/08
- [PATCH 03/17] target/sparc: Use float*_muladd_scalbn, Richard Henderson, 2024/12/08
- [PATCH 04/17] softfloat: Remove float_muladd_halve_result, Richard Henderson, 2024/12/08
- [PATCH 07/17] target/hexagon: Use float32_mul in helper_sfmpy, Richard Henderson, 2024/12/08
- [PATCH 05/17] softfloat: Add float_round_nearest_even_max, Richard Henderson, 2024/12/08
- [PATCH 06/17] softfloat: Add float_muladd_suppress_add_product_zero,
Richard Henderson <=
- [PATCH 08/17] target/hexagon: Use float32_muladd for helper_sffma, Richard Henderson, 2024/12/08
- [PATCH 09/17] target/hexagon: Use float32_muladd for helper_sffms, Richard Henderson, 2024/12/08
- [PATCH 10/17] target/hexagon: Use float32_muladd_scalbn for helper_sffma_sc, Richard Henderson, 2024/12/08
- [PATCH 11/17] target/hexagon: Use float32_muladd for helper_sffm[as]_lib, Richard Henderson, 2024/12/08
- [PATCH 12/17] target/hexagon: Remove internal_fmafx, Richard Henderson, 2024/12/08