[PATCH 25/48] MIPS: math-emu: Optimise NaN handling in comparisons

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
linux-mips-emu-cmp-nan.diff
Index: linux/arch/mips/math-emu/dp_cmp.c
===================================================================
--- linux.orig/arch/mips/math-emu/dp_cmp.c	2015-04-03 13:23:28.348835000 +0100
+++ linux/arch/mips/math-emu/dp_cmp.c	2015-04-03 13:23:31.663867000 +0100
@@ -35,7 +35,7 @@ int ieee754dp_cmp(union ieee754dp x, uni
 	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: linux/arch/mips/math-emu/ieee754dp.c
===================================================================
--- linux.orig/arch/mips/math-emu/ieee754dp.c	2015-04-03 13:23:28.349836000 +0100
+++ linux/arch/mips/math-emu/ieee754dp.c	2015-04-03 13:23:31.665869000 +0100
@@ -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: linux/arch/mips/math-emu/ieee754int.h
===================================================================
--- linux.orig/arch/mips/math-emu/ieee754int.h	2015-04-03 13:23:28.350839000 +0100
+++ linux/arch/mips/math-emu/ieee754int.h	2015-04-03 13:23:31.667874000 +0100
@@ -44,6 +44,11 @@ static inline int ieee754_setandtestcx(c
 	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: linux/arch/mips/math-emu/ieee754sp.c
===================================================================
--- linux.orig/arch/mips/math-emu/ieee754sp.c	2015-04-03 13:23:28.352832000 +0100
+++ linux/arch/mips/math-emu/ieee754sp.c	2015-04-03 13:23:31.678870000 +0100
@@ -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: linux/arch/mips/math-emu/sp_cmp.c
===================================================================
--- linux.orig/arch/mips/math-emu/sp_cmp.c	2015-04-03 13:23:28.354835000 +0100
+++ linux/arch/mips/math-emu/sp_cmp.c	2015-04-03 13:23:31.680870000 +0100
@@ -35,7 +35,7 @@ int ieee754sp_cmp(union ieee754sp x, uni
 	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);





[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux