summaryrefslogtreecommitdiff
path: root/arch/mips/math-emu
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2015-04-04 01:25:43 +0300
committerRalf Baechle <ralf@linux-mips.org>2015-04-08 02:09:38 +0300
commitbd267a53055c1a0fb3a8ad7fa74ae91ece13dcfb (patch)
tree1b649744be5fea36fa5e4875b3d064a346dbcc88 /arch/mips/math-emu
parentc9a1084516e35ff4f1d5b83e77530ed019ca364b (diff)
downloadlinux-bd267a53055c1a0fb3a8ad7fa74ae91ece13dcfb.tar.xz
MIPS: math-emu: Remove redundant code from NaN comparison
Remove a redundant call to `ieee754_setandtestcx' in `ieee754sp_cmp' and `ieee754dp_cmp'. The IEEE 754 exception requested will have already been set by a call to `ieee754_setcx' immediately above, because `sig' has to be non-zero to reach here, and the comparison result returned will be 0 regardless of the result from the call. Simplify the return expression remaining. All this reducing the size of code by 16 and 12 instructions or 64 and 48 bytes respectively. Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/9690/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu')
-rw-r--r--arch/mips/math-emu/dp_cmp.c8
-rw-r--r--arch/mips/math-emu/sp_cmp.c8
2 files changed, 2 insertions, 14 deletions
diff --git a/arch/mips/math-emu/dp_cmp.c b/arch/mips/math-emu/dp_cmp.c
index 99623c12ef03..a29880e29ae4 100644
--- a/arch/mips/math-emu/dp_cmp.c
+++ b/arch/mips/math-emu/dp_cmp.c
@@ -39,13 +39,7 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig)
if (sig ||
xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
ieee754_setcx(IEEE754_INVALID_OPERATION);
- if (cmp & IEEE754_CUN)
- return 1;
- if (cmp & (IEEE754_CLT | IEEE754_CGT)) {
- if (sig && ieee754_setandtestcx(IEEE754_INVALID_OPERATION))
- return 0;
- }
- return 0;
+ return (cmp & IEEE754_CUN) != 0;
} else {
vx = x.bits;
vy = y.bits;
diff --git a/arch/mips/math-emu/sp_cmp.c b/arch/mips/math-emu/sp_cmp.c
index d765ba1c7b82..67b82f1e2c4a 100644
--- a/arch/mips/math-emu/sp_cmp.c
+++ b/arch/mips/math-emu/sp_cmp.c
@@ -39,13 +39,7 @@ int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig)
if (sig ||
xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
ieee754_setcx(IEEE754_INVALID_OPERATION);
- if (cmp & IEEE754_CUN)
- return 1;
- if (cmp & (IEEE754_CLT | IEEE754_CGT)) {
- if (sig && ieee754_setandtestcx(IEEE754_INVALID_OPERATION))
- return 0;
- }
- return 0;
+ return (cmp & IEEE754_CUN) != 0;
} else {
vx = x.bits;
vy = y.bits;