]>
Commit | Line | Data |
---|---|---|
dbfa5f4f GKH |
1 | From 1a41b3b441508ae63b1a9ec699ec94065739eb60 Mon Sep 17 00:00:00 2001 |
2 | From: Aleksandar Markovic <aleksandar.markovic@imgtec.com> | |
3 | Date: Thu, 27 Jul 2017 18:08:51 +0200 | |
4 | Subject: MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs | |
5 | ||
6 | From: Aleksandar Markovic <aleksandar.markovic@imgtec.com> | |
7 | ||
8 | commit 1a41b3b441508ae63b1a9ec699ec94065739eb60 upstream. | |
9 | ||
10 | Fix the value returned by <MAXA|MINA>.<D|S>, if the inputs are normal | |
11 | fp numbers of the same absolute value, but opposite signs. | |
12 | ||
13 | A relevant example: | |
14 | ||
15 | MAXA.S fd,fs,ft: | |
16 | If fs contains -3.0, and ft contains +3.0, fd is going to contain | |
17 | +3.0 (without this patch, it used to contain -3.0). | |
18 | ||
19 | Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction") | |
20 | Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction") | |
21 | ||
22 | Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> | |
23 | Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com> | |
24 | Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> | |
25 | Reviewed-by: James Hogan <james.hogan@imgtec.com> | |
26 | Cc: Bo Hu <bohu@google.com> | |
27 | Cc: Douglas Leung <douglas.leung@imgtec.com> | |
28 | Cc: Jin Qian <jinqian@google.com> | |
29 | Cc: Paul Burton <paul.burton@imgtec.com> | |
30 | Cc: Petar Jovanovic <petar.jovanovic@imgtec.com> | |
31 | Cc: Raghu Gandham <raghu.gandham@imgtec.com> | |
32 | Cc: linux-mips@linux-mips.org | |
33 | Cc: linux-kernel@vger.kernel.org | |
34 | Patchwork: https://patchwork.linux-mips.org/patch/16883/ | |
35 | Signed-off-by: Ralf Baechle <ralf@linux-mips.org> | |
36 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
37 | ||
38 | --- | |
39 | arch/mips/math-emu/dp_fmax.c | 8 ++++++-- | |
40 | arch/mips/math-emu/dp_fmin.c | 6 +++++- | |
41 | arch/mips/math-emu/sp_fmax.c | 8 ++++++-- | |
42 | arch/mips/math-emu/sp_fmin.c | 6 +++++- | |
43 | 4 files changed, 22 insertions(+), 6 deletions(-) | |
44 | ||
45 | --- a/arch/mips/math-emu/dp_fmax.c | |
46 | +++ b/arch/mips/math-emu/dp_fmax.c | |
47 | @@ -243,7 +243,11 @@ union ieee754dp ieee754dp_fmaxa(union ie | |
48 | return y; | |
49 | ||
50 | /* Compare mantissa */ | |
51 | - if (xm <= ym) | |
52 | + if (xm < ym) | |
53 | return y; | |
54 | - return x; | |
55 | + else if (xm > ym) | |
56 | + return x; | |
57 | + else if (xs == 0) | |
58 | + return x; | |
59 | + return y; | |
60 | } | |
61 | --- a/arch/mips/math-emu/dp_fmin.c | |
62 | +++ b/arch/mips/math-emu/dp_fmin.c | |
63 | @@ -243,7 +243,11 @@ union ieee754dp ieee754dp_fmina(union ie | |
64 | return x; | |
65 | ||
66 | /* Compare mantissa */ | |
67 | - if (xm <= ym) | |
68 | + if (xm < ym) | |
69 | + return x; | |
70 | + else if (xm > ym) | |
71 | + return y; | |
72 | + else if (xs == 1) | |
73 | return x; | |
74 | return y; | |
75 | } | |
76 | --- a/arch/mips/math-emu/sp_fmax.c | |
77 | +++ b/arch/mips/math-emu/sp_fmax.c | |
78 | @@ -243,7 +243,11 @@ union ieee754sp ieee754sp_fmaxa(union ie | |
79 | return y; | |
80 | ||
81 | /* Compare mantissa */ | |
82 | - if (xm <= ym) | |
83 | + if (xm < ym) | |
84 | return y; | |
85 | - return x; | |
86 | + else if (xm > ym) | |
87 | + return x; | |
88 | + else if (xs == 0) | |
89 | + return x; | |
90 | + return y; | |
91 | } | |
92 | --- a/arch/mips/math-emu/sp_fmin.c | |
93 | +++ b/arch/mips/math-emu/sp_fmin.c | |
94 | @@ -243,7 +243,11 @@ union ieee754sp ieee754sp_fmina(union ie | |
95 | return x; | |
96 | ||
97 | /* Compare mantissa */ | |
98 | - if (xm <= ym) | |
99 | + if (xm < ym) | |
100 | + return x; | |
101 | + else if (xm > ym) | |
102 | + return y; | |
103 | + else if (xs == 1) | |
104 | return x; | |
105 | return y; | |
106 | } |