[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 6/9] hardfloat: fix float32/64 fused multiply-add
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PULL 6/9] hardfloat: fix float32/64 fused multiply-add |
Date: |
Mon, 25 Mar 2019 13:20:06 +0000 |
From: Kito Cheng <address@hidden>
Before falling back to softfloat FMA, we do not restore the original
values of inputs A and C. Fix it.
This bug was caught by running gcc's testsuite on RISC-V qemu.
Note that this change gives a small perf increase for fp-bench:
Host: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Command: perf stat -r 3 taskset -c 0 ./fp-bench -o mulAdd -p $prec
- $prec = single:
- before:
101.71 MFlops
102.18 MFlops
100.96 MFlops
- after:
103.63 MFlops
103.05 MFlops
102.96 MFlops
- $prec = double:
- before:
173.10 MFlops
173.93 MFlops
172.11 MFlops
- after:
178.49 MFlops
178.88 MFlops
178.66 MFlops
Signed-off-by: Kito Cheng <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 4610738ab1..2ba36ec370 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1596,6 +1596,9 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int
flags, float_status *s)
}
ur.h = up.h + uc.h;
} else {
+ union_float32 ua_orig = ua;
+ union_float32 uc_orig = uc;
+
if (flags & float_muladd_negate_product) {
ua.h = -ua.h;
}
@@ -1608,6 +1611,8 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int
flags, float_status *s)
if (unlikely(f32_is_inf(ur))) {
s->float_exception_flags |= float_flag_overflow;
} else if (unlikely(fabsf(ur.h) <= FLT_MIN)) {
+ ua = ua_orig;
+ uc = uc_orig;
goto soft;
}
}
@@ -1662,6 +1667,9 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int
flags, float_status *s)
}
ur.h = up.h + uc.h;
} else {
+ union_float64 ua_orig = ua;
+ union_float64 uc_orig = uc;
+
if (flags & float_muladd_negate_product) {
ua.h = -ua.h;
}
@@ -1674,6 +1682,8 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int
flags, float_status *s)
if (unlikely(f64_is_inf(ur))) {
s->float_exception_flags |= float_flag_overflow;
} else if (unlikely(fabs(ur.h) <= FLT_MIN)) {
+ ua = ua_orig;
+ uc = uc_orig;
goto soft;
}
}
--
2.20.1
- [Qemu-devel] [PULL 0/9 for 4.0] fpu and testing fixes, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 1/9] configure: add --target-list-exclude, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 3/9] .travis.yml: --disable-user for --without-default-devices, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 2/9] .travis.yml: split some more system builds, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 4/9] .travis.yml: reduce number of targets built while disabling things, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 7/9] docker: Fix travis.py parser and misc change, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 6/9] hardfloat: fix float32/64 fused multiply-add,
Alex Bennée <=
- [Qemu-devel] [PULL 5/9] target/mips: Fix minor bug in FPU, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 8/9] docker: Fix travis script unable to find source dir, Alex Bennée, 2019/03/25
- [Qemu-devel] [PULL 9/9] docker: trivial changes to `make docker` help, Alex Bennée, 2019/03/25
- Re: [Qemu-devel] [PULL 0/9 for 4.0] fpu and testing fixes, Peter Maydell, 2019/03/25