diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2015-04-03 18:25:38 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-04-07 19:09:35 -0400 |
commit | c9a1084516e35ff4f1d5b83e77530ed019ca364b (patch) | |
tree | de1cfa5b17d0e2db63616994f42fb12de8b207c6 /arch/mips/math-emu | |
parent | d5afa7e905544a3d9e2bb29d9cafebc8e544c978 (diff) |
MIPS: math-emu: Optimise NaN handling in comparisons
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>
Diffstat (limited to 'arch/mips/math-emu')
-rw-r--r-- | arch/mips/math-emu/dp_cmp.c | 2 | ||||
-rw-r--r-- | arch/mips/math-emu/ieee754dp.c | 2 | ||||
-rw-r--r-- | arch/mips/math-emu/ieee754int.h | 5 | ||||
-rw-r--r-- | arch/mips/math-emu/ieee754sp.c | 2 | ||||
-rw-r--r-- | arch/mips/math-emu/sp_cmp.c | 2 |
5 files changed, 9 insertions, 4 deletions
diff --git a/arch/mips/math-emu/dp_cmp.c b/arch/mips/math-emu/dp_cmp.c index f8fbb23bd0fb..99623c12ef03 100644 --- a/arch/mips/math-emu/dp_cmp.c +++ b/arch/mips/math-emu/dp_cmp.c | |||
@@ -35,7 +35,7 @@ int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig) | |||
35 | FLUSHYDP; | 35 | FLUSHYDP; |
36 | ieee754_clearcx(); /* Even clear inexact flag here */ | 36 | ieee754_clearcx(); /* Even clear inexact flag here */ |
37 | 37 | ||
38 | if (ieee754dp_isnan(x) || ieee754dp_isnan(y)) { | 38 | if (ieee754_class_nan(xc) || ieee754_class_nan(yc)) { |
39 | if (sig || | 39 | if (sig || |
40 | xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) | 40 | xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) |
41 | ieee754_setcx(IEEE754_INVALID_OPERATION); | 41 | ieee754_setcx(IEEE754_INVALID_OPERATION); |
diff --git a/arch/mips/math-emu/ieee754dp.c b/arch/mips/math-emu/ieee754dp.c index 49c811a920b5..921535b5c3a6 100644 --- a/arch/mips/math-emu/ieee754dp.c +++ b/arch/mips/math-emu/ieee754dp.c | |||
@@ -32,7 +32,7 @@ int ieee754dp_class(union ieee754dp x) | |||
32 | 32 | ||
33 | int ieee754dp_isnan(union ieee754dp x) | 33 | int ieee754dp_isnan(union ieee754dp x) |
34 | { | 34 | { |
35 | return ieee754dp_class(x) >= IEEE754_CLASS_SNAN; | 35 | return ieee754_class_nan(ieee754dp_class(x)); |
36 | } | 36 | } |
37 | 37 | ||
38 | static inline int ieee754dp_issnan(union ieee754dp x) | 38 | static inline int ieee754dp_issnan(union ieee754dp x) |
diff --git a/arch/mips/math-emu/ieee754int.h b/arch/mips/math-emu/ieee754int.h index f0365bb86747..05389d5e3a93 100644 --- a/arch/mips/math-emu/ieee754int.h +++ b/arch/mips/math-emu/ieee754int.h | |||
@@ -44,6 +44,11 @@ static inline int ieee754_setandtestcx(const unsigned int x) | |||
44 | return ieee754_csr.mx & x; | 44 | return ieee754_csr.mx & x; |
45 | } | 45 | } |
46 | 46 | ||
47 | static inline int ieee754_class_nan(int xc) | ||
48 | { | ||
49 | return xc >= IEEE754_CLASS_SNAN; | ||
50 | } | ||
51 | |||
47 | #define COMPXSP \ | 52 | #define COMPXSP \ |
48 | unsigned xm; int xe; int xs __maybe_unused; int xc | 53 | unsigned xm; int xe; int xs __maybe_unused; int xc |
49 | 54 | ||
diff --git a/arch/mips/math-emu/ieee754sp.c b/arch/mips/math-emu/ieee754sp.c index 21899ce05171..e48aaab1543b 100644 --- a/arch/mips/math-emu/ieee754sp.c +++ b/arch/mips/math-emu/ieee754sp.c | |||
@@ -32,7 +32,7 @@ int ieee754sp_class(union ieee754sp x) | |||
32 | 32 | ||
33 | int ieee754sp_isnan(union ieee754sp x) | 33 | int ieee754sp_isnan(union ieee754sp x) |
34 | { | 34 | { |
35 | return ieee754sp_class(x) >= IEEE754_CLASS_SNAN; | 35 | return ieee754_class_nan(ieee754sp_class(x)); |
36 | } | 36 | } |
37 | 37 | ||
38 | static inline int ieee754sp_issnan(union ieee754sp x) | 38 | static inline int ieee754sp_issnan(union ieee754sp x) |
diff --git a/arch/mips/math-emu/sp_cmp.c b/arch/mips/math-emu/sp_cmp.c index 5caf088af0d7..d765ba1c7b82 100644 --- a/arch/mips/math-emu/sp_cmp.c +++ b/arch/mips/math-emu/sp_cmp.c | |||
@@ -35,7 +35,7 @@ int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig) | |||
35 | FLUSHYSP; | 35 | FLUSHYSP; |
36 | ieee754_clearcx(); /* Even clear inexact flag here */ | 36 | ieee754_clearcx(); /* Even clear inexact flag here */ |
37 | 37 | ||
38 | if (ieee754sp_isnan(x) || ieee754sp_isnan(y)) { | 38 | if (ieee754_class_nan(xc) || ieee754_class_nan(yc)) { |
39 | if (sig || | 39 | if (sig || |
40 | xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) | 40 | xc == IEEE754_CLASS_SNAN || yc == IEEE754_CLASS_SNAN) |
41 | ieee754_setcx(IEEE754_INVALID_OPERATION); | 41 | ieee754_setcx(IEEE754_INVALID_OPERATION); |