[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/9] target/mips: Fix minor bug in FPU
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PULL 5/9] target/mips: Fix minor bug in FPU |
Date: |
Mon, 25 Mar 2019 13:20:05 +0000 |
From: Mateja Marjanovic <address@hidden>
Wrong type of NaN was generated for IEEE 754-2008 by MADDF.<D|S> and
MSUBF.<D|S> instructions when the arguments were (Inf, Zero, NaN) or
(Zero, Inf, NaN).
The if-else statement establishes if the system conforms to IEEE
754-1985 or IEEE 754-2008, and defines different behaviors depending
on that. In case of IEEE 754-2008, in mentioned cases of inputs,
<MADDF|MSUBF>.<D|S> returns the input value 'c' [2] (page 53) and
raises floating point exception 'Invalid Operation' [1] (pages 349,
350).
These scenarios were tested and the results in QEMU emulation match
the results obtained on the machine that has a MIPS64R6 CPU.
[1] MIPS Architecture for Programmers Volume II-a: The MIPS64
Instruction Set Reference Manual, Revision 6.06
[2] MIPS Architecture for Programmers Volume IV-j: The MIPS64
SIMD Architecture Module, Revision 1.12
Signed-off-by: Mateja Marjanovic <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
[AJB: fixed up commit message]
Signed-off-by: Alex Bennée <address@hidden>
diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index 16c0bcb6fa..7b8895726c 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -495,15 +495,15 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass
b_cls, FloatClass c_cls,
return 1;
}
#elif defined(TARGET_MIPS)
- /* For MIPS, the (inf,zero,qnan) case sets InvalidOp and returns
- * the default NaN
- */
- if (infzero) {
- float_raise(float_flag_invalid, status);
- return 3;
- }
-
if (snan_bit_is_one(status)) {
+ /*
+ * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
+ * case sets InvalidOp and returns the default NaN
+ */
+ if (infzero) {
+ float_raise(float_flag_invalid, status);
+ return 3;
+ }
/* Prefer sNaN over qNaN, in the a, b, c order. */
if (is_snan(a_cls)) {
return 0;
@@ -519,6 +519,14 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass
b_cls, FloatClass c_cls,
return 2;
}
} else {
+ /*
+ * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
+ * case sets InvalidOp and returns the input value 'c'
+ */
+ if (infzero) {
+ float_raise(float_flag_invalid, status);
+ return 2;
+ }
/* Prefer sNaN over qNaN, in the c, a, b order. */
if (is_snan(c_cls)) {
return 2;
--
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, 2019/03/25
- [Qemu-devel] [PULL 5/9] target/mips: Fix minor bug in FPU,
Alex Bennée <=
- [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