]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
MIPS: math-emu: Optimise NaN handling in comparisons
authorMaciej W. Rozycki <macro@linux-mips.org>
Fri, 3 Apr 2015 22:25:38 +0000 (23:25 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 7 Apr 2015 23:09:35 +0000 (01:09 +0200)
We have the input operands already classified in `ieee754sp_cmp' and
`ieee754dp_cmp' comparison operations, so use the class obtained to tell
NaNs and numbers apart rather than classifying inputs again for this
purpose, reducing the size of code by 24 and 40 instructions or 96 and
160 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/9689/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/math-emu/dp_cmp.c
arch/mips/math-emu/ieee754dp.c
arch/mips/math-emu/ieee754int.h
arch/mips/math-emu/ieee754sp.c
arch/mips/math-emu/sp_cmp.c

index f8fbb23bd0fb845f13e9407147338fdd2e6764f9..99623c12ef03f894d7590c4b2bfa7fbdbdf60262 100644 (file)
@@ -35,7 +35,7 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig)
        FLUSHYDP;
        ieee754_clearcx();      /* Even clear inexact flag here */
 
-       if (ieee754dp_isnan(x) || ieee754dp_isnan(y)) {
+       if (ieee754_class_nan(xc) || ieee754_class_nan(yc)) {
                if (sig ||
                    xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
                        ieee754_setcx(IEEE754_INVALID_OPERATION);
index 49c811a920b532d82910ac9732e0643fa25eb4e7..921535b5c3a6d01f6305a4f53180f303ff53af92 100644 (file)
@@ -32,7 +32,7 @@ int ieee754dp_class(union ieee754dp x)
 
 int ieee754dp_isnan(union ieee754dp x)
 {
-       return ieee754dp_class(x) >= IEEE754_CLASS_SNAN;
+       return ieee754_class_nan(ieee754dp_class(x));
 }
 
 static inline int ieee754dp_issnan(union ieee754dp x)
index f0365bb86747db8a64ddaff74eb9eb1b90e4cef2..05389d5e3a933d7dbee1e728adb0b40b1f795599 100644 (file)
@@ -44,6 +44,11 @@ static inline int ieee754_setandtestcx(const unsigned int x)
        return ieee754_csr.mx & x;
 }
 
+static inline int ieee754_class_nan(int xc)
+{
+       return xc >= IEEE754_CLASS_SNAN;
+}
+
 #define COMPXSP \
        unsigned xm; int xe; int xs __maybe_unused; int xc
 
index 21899ce05171e2bf291a2ff89320556eb8e1673f..e48aaab1543bcf3125ac7b6965913fa847efa1f4 100644 (file)
@@ -32,7 +32,7 @@ int ieee754sp_class(union ieee754sp x)
 
 int ieee754sp_isnan(union ieee754sp x)
 {
-       return ieee754sp_class(x) >= IEEE754_CLASS_SNAN;
+       return ieee754_class_nan(ieee754sp_class(x));
 }
 
 static inline int ieee754sp_issnan(union ieee754sp x)
index 5caf088af0d724dd4149c87c116cc998c6a1fc94..d765ba1c7b82ce57d358ed1c9c175f57a83d7442 100644 (file)
@@ -35,7 +35,7 @@ int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig)
        FLUSHYSP;
        ieee754_clearcx();      /* Even clear inexact flag here */
 
-       if (ieee754sp_isnan(x) || ieee754sp_isnan(y)) {
+       if (ieee754_class_nan(xc) || ieee754_class_nan(yc)) {
                if (sig ||
                    xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN)
                        ieee754_setcx(IEEE754_INVALID_OPERATION);