Skip to content

Commit ddbfff7

Browse files
aleksandar-markovicralfbaechle
authored andcommitted
MIPS: math-emu: Handle zero accumulator case in MADDF and MSUBF separately
If accumulator value is zero, just return the value of previously calculated product. This brings logic in MADDF/MSUBF implementation closer to the logic in ADD/SUB case. Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Cc: James.Hogan@imgtec.com Cc: Paul.Burton@imgtec.com Cc: Raghu.Gandham@imgtec.com Cc: Leonid.Yegoshin@imgtec.com Cc: Douglas.Leung@imgtec.com Cc: Petar.Jovanovic@imgtec.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16512/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 25d8b92 commit ddbfff7

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎arch/mips/math-emu/dp_maddf.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x,
5454
return ieee754dp_nanxcpt(z);
5555
case IEEE754_CLASS_DNORM:
5656
DPDNORMZ;
57-
/* QNAN is handled separately below */
57+
/* QNAN and ZERO cases are handled separately below */
5858
}
5959

6060
switch (CLPAIR(xc, yc)) {
@@ -210,6 +210,9 @@ static union ieee754dp _dp_maddf(union ieee754dp z, union ieee754dp x,
210210
}
211211
assert(rm & (DP_HIDDEN_BIT << 3));
212212

213+
if (zc == IEEE754_CLASS_ZERO)
214+
return ieee754dp_format(rs, re, rm);
215+
213216
/* And now the addition */
214217
assert(zm & DP_HIDDEN_BIT);
215218

‎arch/mips/math-emu/sp_maddf.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
5454
return ieee754sp_nanxcpt(z);
5555
case IEEE754_CLASS_DNORM:
5656
SPDNORMZ;
57-
/* QNAN is handled separately below */
57+
/* QNAN and ZERO cases are handled separately below */
5858
}
5959

6060
switch (CLPAIR(xc, yc)) {
@@ -203,6 +203,9 @@ static union ieee754sp _sp_maddf(union ieee754sp z, union ieee754sp x,
203203
}
204204
assert(rm & (SP_HIDDEN_BIT << 3));
205205

206+
if (zc == IEEE754_CLASS_ZERO)
207+
return ieee754sp_format(rs, re, rm);
208+
206209
/* And now the addition */
207210

208211
assert(zm & SP_HIDDEN_BIT);

0 commit comments

Comments
 (0)