about summary refs log tree commit diff
path: root/soft-fp/soft-fp.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-10-09 01:09:22 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-10-09 01:09:22 +0000
commit454ac701e3639bfcb8919706319a685341536eda (patch)
tree43a1bf6afd55b21347b743266adeb6c3048f272f /soft-fp/soft-fp.h
parent0022e688d082761a1e15b19121303cafbdad33ec (diff)
downloadglibc-454ac701e3639bfcb8919706319a685341536eda.tar.gz
glibc-454ac701e3639bfcb8919706319a685341536eda.tar.xz
glibc-454ac701e3639bfcb8919706319a685341536eda.zip
soft-fp: Add FP_DENORM_ZERO.
Continuing the addition of soft-fp features used in the Linux kernel,
this patch adds soft-fp support for FP_DENORM_ZERO (flushing input
subnormal operands to zero of the same sign).

There are some differences from the kernel version.  In the kernel,
the "inexact" exception is set when flushing to zero.  This does not
appear to match the documented semantics for either of the
architectures (alpha and sh) for which the kernel uses FP_DENORM_ZERO,
so this patch does not set "inexact" in this case.  More operations
now use raw or semi-raw unpacking for optimization than did in the
ten-year-old soft-fp version in the kernel, so checks of
FP_DENORM_ZERO are inserted in those operations.  They are also
inserted for comparisons (which already used raw unpacking in the old
version) as I believe that's the correct thing to do when input
subnormals are flushed to zero.  They are *not* inserted for _FP_NEG.
(If any processors do flush input subnormals to zero for negation, or
otherwise vary from the rules implemented when FP_DENORM_ZERO is set,
further macros for sfp-machine.h to control this may need to be
added.)

Although the addition for comparisons will cause FP_EX_DENORM to be
set in this case, it still won't be set for comparisons involving
subnormals when not flushed to zero.  It's quite possible that
accurate emulation of processors that have such an exception for
subnormal operands will require further changes relating to when
FP_EX_DENORM is set (in general, the support for things defined by
IEEE should be considered more reliable and mature than the support
for things outside the scope of IEEE floating point).

Although some processors also have a mode for abrupt underflow -
producing zeroes instead of output subnormals - there is no such mode
in the kernel's soft-fp, so no such mode is added to glibc's soft-fp
(although it could be if someone wanted to emulate such processor
support).

Tested for powerpc-nofpu that the disassembly of installed shared
libraries is unchanged by this patch.

	* soft-fp/soft-fp.h (FP_DENORM_ZERO): New macro.
	* soft-fp/op-common.h (_FP_UNPACK_CANONICAL): Check
	FP_DENORM_ZERO.
	(_FP_CHECK_FLUSH_ZERO): New macro.
	(_FP_ADD_INTERNAL): Call _FP_CHECK_FLUSH_ZERO.
	(_FP_CMP): Likewise.
	(_FP_CMP_EQ): Likewise.
	(_FP_TO_INT): Do not set inexact for subnormal arguments if
	FP_DENORM_ZERO.
	(FP_EXTEND): Call _FP_CHECK_FLUSH_ZERO.
	(FP_TRUNC): Likewise.
Diffstat (limited to 'soft-fp/soft-fp.h')
-rw-r--r--soft-fp/soft-fp.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h
index 4018b0ee91..3ac269ecf7 100644
--- a/soft-fp/soft-fp.h
+++ b/soft-fp/soft-fp.h
@@ -123,6 +123,11 @@
 # define FP_HANDLE_EXCEPTIONS do {} while (0)
 #endif
 
+/* Whether to flush subnormal inputs to zero with the same sign.  */
+#ifndef FP_DENORM_ZERO
+# define FP_DENORM_ZERO 0
+#endif
+
 #ifndef FP_INHIBIT_RESULTS
 /* By default we write the results always.
    sfp-machine may override this and e.g.