]>
Commit | Line | Data |
---|---|---|
dbfa5f4f GKH |
1 | From 15560a58bfd4ff82cdd16b2270d4ef9b06d2cc4d Mon Sep 17 00:00:00 2001 |
2 | From: Aleksandar Markovic <aleksandar.markovic@imgtec.com> | |
3 | Date: Thu, 27 Jul 2017 18:08:49 +0200 | |
4 | Subject: MIPS: math-emu: <MAX|MAXA|MIN|MINA>.<D|S>: Fix cases of both inputs zero | |
5 | ||
6 | From: Aleksandar Markovic <aleksandar.markovic@imgtec.com> | |
7 | ||
8 | commit 15560a58bfd4ff82cdd16b2270d4ef9b06d2cc4d upstream. | |
9 | ||
10 | Fix the value returned by <MAX|MAXA|MIN|MINA>.<D|S>, if both inputs | |
11 | are zeros. The right behavior in such cases is stated in instruction | |
12 | reference manual and is as follows: | |
13 | ||
14 | fs ft MAX MIN MAXA MINA | |
15 | --------------------------------------------- | |
16 | 0 0 0 0 0 0 | |
17 | 0 -0 0 -0 0 -0 | |
18 | -0 0 0 -0 0 -0 | |
19 | -0 -0 -0 -0 -0 -0 | |
20 | ||
21 | Prior to this patch, some of the above cases were yielding correct | |
22 | results. However, for the sake of code consistency, all such cases | |
23 | are rewritten in this patch. | |
24 | ||
25 | A relevant example: | |
26 | ||
27 | MAX.S fd,fs,ft: | |
28 | If fs contains +0.0, and ft contains -0.0, fd is going to contain | |
29 | +0.0 (without this patch, it used to contain -0.0). | |
30 | ||
31 | Fixes: a79f5f9ba508 ("MIPS: math-emu: Add support for the MIPS R6 MAX{, A} FPU instruction") | |
32 | Fixes: 4e9561b20e2f ("MIPS: math-emu: Add support for the MIPS R6 MIN{, A} FPU instruction") | |
33 | ||
34 | Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> | |
35 | Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com> | |
36 | Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> | |
37 | Reviewed-by: James Hogan <james.hogan@imgtec.com> | |
38 | Cc: Bo Hu <bohu@google.com> | |
39 | Cc: Douglas Leung <douglas.leung@imgtec.com> | |
40 | Cc: Jin Qian <jinqian@google.com> | |
41 | Cc: Paul Burton <paul.burton@imgtec.com> | |
42 | Cc: Petar Jovanovic <petar.jovanovic@imgtec.com> | |
43 | Cc: Raghu Gandham <raghu.gandham@imgtec.com> | |
44 | Cc: linux-mips@linux-mips.org | |
45 | Cc: linux-kernel@vger.kernel.org | |
46 | Patchwork: https://patchwork.linux-mips.org/patch/16881/ | |
47 | Signed-off-by: Ralf Baechle <ralf@linux-mips.org> | |
48 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
49 | ||
50 | --- | |
51 | arch/mips/math-emu/dp_fmax.c | 8 ++------ | |
52 | arch/mips/math-emu/dp_fmin.c | 8 ++------ | |
53 | arch/mips/math-emu/sp_fmax.c | 8 ++------ | |
54 | arch/mips/math-emu/sp_fmin.c | 8 ++------ | |
55 | 4 files changed, 8 insertions(+), 24 deletions(-) | |
56 | ||
57 | --- a/arch/mips/math-emu/dp_fmax.c | |
58 | +++ b/arch/mips/math-emu/dp_fmax.c | |
59 | @@ -92,9 +92,7 @@ union ieee754dp ieee754dp_fmax(union iee | |
60 | return ys ? x : y; | |
61 | ||
62 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
63 | - if (xs == ys) | |
64 | - return x; | |
65 | - return ieee754dp_zero(1); | |
66 | + return ieee754dp_zero(xs & ys); | |
67 | ||
68 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
69 | DPDNORMX; | |
70 | @@ -204,9 +202,7 @@ union ieee754dp ieee754dp_fmaxa(union ie | |
71 | return y; | |
72 | ||
73 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
74 | - if (xs == ys) | |
75 | - return x; | |
76 | - return ieee754dp_zero(1); | |
77 | + return ieee754dp_zero(xs & ys); | |
78 | ||
79 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
80 | DPDNORMX; | |
81 | --- a/arch/mips/math-emu/dp_fmin.c | |
82 | +++ b/arch/mips/math-emu/dp_fmin.c | |
83 | @@ -92,9 +92,7 @@ union ieee754dp ieee754dp_fmin(union iee | |
84 | return ys ? y : x; | |
85 | ||
86 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
87 | - if (xs == ys) | |
88 | - return x; | |
89 | - return ieee754dp_zero(1); | |
90 | + return ieee754dp_zero(xs | ys); | |
91 | ||
92 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
93 | DPDNORMX; | |
94 | @@ -204,9 +202,7 @@ union ieee754dp ieee754dp_fmina(union ie | |
95 | return y; | |
96 | ||
97 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
98 | - if (xs == ys) | |
99 | - return x; | |
100 | - return ieee754dp_zero(1); | |
101 | + return ieee754dp_zero(xs | ys); | |
102 | ||
103 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
104 | DPDNORMX; | |
105 | --- a/arch/mips/math-emu/sp_fmax.c | |
106 | +++ b/arch/mips/math-emu/sp_fmax.c | |
107 | @@ -92,9 +92,7 @@ union ieee754sp ieee754sp_fmax(union iee | |
108 | return ys ? x : y; | |
109 | ||
110 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
111 | - if (xs == ys) | |
112 | - return x; | |
113 | - return ieee754sp_zero(1); | |
114 | + return ieee754sp_zero(xs & ys); | |
115 | ||
116 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
117 | SPDNORMX; | |
118 | @@ -204,9 +202,7 @@ union ieee754sp ieee754sp_fmaxa(union ie | |
119 | return y; | |
120 | ||
121 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
122 | - if (xs == ys) | |
123 | - return x; | |
124 | - return ieee754sp_zero(1); | |
125 | + return ieee754sp_zero(xs & ys); | |
126 | ||
127 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
128 | SPDNORMX; | |
129 | --- a/arch/mips/math-emu/sp_fmin.c | |
130 | +++ b/arch/mips/math-emu/sp_fmin.c | |
131 | @@ -92,9 +92,7 @@ union ieee754sp ieee754sp_fmin(union iee | |
132 | return ys ? y : x; | |
133 | ||
134 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
135 | - if (xs == ys) | |
136 | - return x; | |
137 | - return ieee754sp_zero(1); | |
138 | + return ieee754sp_zero(xs | ys); | |
139 | ||
140 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
141 | SPDNORMX; | |
142 | @@ -204,9 +202,7 @@ union ieee754sp ieee754sp_fmina(union ie | |
143 | return y; | |
144 | ||
145 | case CLPAIR(IEEE754_CLASS_ZERO, IEEE754_CLASS_ZERO): | |
146 | - if (xs == ys) | |
147 | - return x; | |
148 | - return ieee754sp_zero(1); | |
149 | + return ieee754sp_zero(xs | ys); | |
150 | ||
151 | case CLPAIR(IEEE754_CLASS_DNORM, IEEE754_CLASS_DNORM): | |
152 | SPDNORMX; |