Software floating point in GCC

Software floating point in GCC currently uses config/fp-bit.c, with some special case support code in mklibgcc.in, plus target-specific assembly implementations for some targets. In addition, libgcc2.c contains generic implementations of conversions of floating point to and from signed and unsigned DImode (or TImode on 64-bit targets), and of conversions from floating point to unsigned SImode, used on all targets unless they expand such conversions inline or use system library functions via set_conv_libfunc.

fp-bit.c is a rather inefficient implementation of software floating point. Some years ago Torbjorn Granlund posted an alternative implementation, ieeelib; see http://gcc.gnu.org/ml/gcc/2005-11/msg01373.html for discussion and references.

GNU libc has a third implementation, soft-fp. (Variants of this are also used for Linux kernel math emulation on some targets.) soft-fp is used in glibc on PowerPC --without-fp to provide the same soft-float functions as in libgcc. It is also used on Alpha, SPARC and PowerPC to provide some ABI-specified floating-point functions (which in turn may get used by GCC); on PowerPC these are IEEE quad functions, not IBM long double ones.

Performance measurements with EEMBC indicate that soft-fp (as speeded up somewhat using ideas from ieeelib) is about 10-15% faster than fp-bit and ieeelib about 1% faster than soft-fp, testing on IBM PowerPC 405 and 440. These are geometric mean measurements across EEMBC; some tests are several times faster with soft-fp than with fp-bit if they make heavy use of floating point, while others don't make significant use of floating point. Depending on the particular test, either soft-fp or ieeelib may be faster; for example, soft-fp is somewhat faster on Whetstone.

Each implementation differs in what features it supports:

In view of the greater maintainabilty associated with the macro structure of soft-fp, and the optional exception and rounding mode support, it seems best to use soft-fp but with ideas and algorithms from ieeelib put in the macro structure of soft-fp to speed up soft-fp. RMS has approved using soft-fp under the GPL+exception licence used for libgcc (instead of LGPL as used for glibc).

The differences between soft-fp and ieeelib essentially are:

To speed up soft-fp, a "semi-raw" unpacking mode has been added which is closer to that used by ieeelib, and this mode is used for various operations. These improvements have been committed to glibc CVS. The improved soft-fp has been committed to csl-ppc4xx-branch. Several bugs have been found and fixed in soft-fp in the process.

Future projects

It is intended to merge soft-fp from csl-ppc4xx-branch to mainline as an alternative software floating point implementation to fp-bit, and to make it the one used on powerpc-linux. It is hoped that it can be used on other targets as well to replace fp-bit.c (possibly adding some features to soft-fp required for particular targets). For each such target, soft-fp needs benchmarking and testing for correctness. IEEE floating-point test software is discussed at http://www.math.utah.edu/%7ebeebe/software/ieee/ ; paranoia and ucbtest are of particular use.

Some more specific projects and issues are:

None: Software_floating_point (last edited 2008-01-10 19:38:35 by localhost)