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

Bug#212912: Documentation and -ffast-math Patch



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The attached Alpha GCC IEEE patch (which is even smaller, and possibly 
clearner, than the original *grin*):

1)  Removes -mno-ieee.
2)  Causes the compiler to turn on -mieee if -ffinite-math-only has not been 
specified.
3)  Updates the documentation to make it clear what is Debian specific.

One should not cause anyone any problems, as no actual gcc versions have been 
compiled with my previous patch (the patch I submitted was included but not 
enabled).  Two and three address Falk's request for -ffast-math to disable 
- -mieee (-ffast-math turns on the -ffinite-math-only) and for the 
documentation to be clear that this is a Debian speciality.

With this patch, if you don't want support for NaNs or Infs (i.e. what -mieee 
enables), turn on -ffinite-math-only (or the larger subset -ffast-math).  
This makes good sense, as the manual says -ffinite-math only "allow[s] 
optimizations for floating-point arithmetic that assume that arguments and 
results are not NaNs or +-Infs".

Slightly off topic, but good to know, is that -ffast-math causes crtfastmath.o 
to be linked into the executable.  This code sets the FPU to map denormals 
and underflows to zero (i.e. code compiled with -ffast-math runs without 
- -mieee and does not SIGFPE over denormals).

- -T

PS:  This patch is meant to be applied directly against the current tree (i.e. 
the tree that contains the original alpha-ieee.dpatch file I submitted and 
has not had the second patch I submitted (i.e. the rules.patch file modified 
to actually include the alpha-ieee.dpatch file in the build).

- -- 
 Tyson Whitehead  (-twhitehe@uwo.ca -- WSC-)
 Computer Engineer                        Dept. of Applied Mathematics,
 Graduate Student- Applied Mathematics    University of Western Ontario,
 GnuPG Key ID# 0x8A2AB5D8                 London, Ontario, Canada
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAAxejRXbLmIoqtdgRAlPFAJ9zfJnigN8pn+bjkVQLH+mPPxEbYwCeMv35
hDA8sTohieCBF9fSL/s/+eo=
=RT8i
-----END PGP SIGNATURE-----
--- debian/patches/alpha-ieee.dpatch_	2004-01-06 11:31:19.000000000 -0500
+++ debian/patches/alpha-ieee.dpatch	2004-01-06 11:32:24.000000000 -0500
@@ -29,58 +29,27 @@
 
 
---- src/gcc/config.gcc.orig	2003-07-13 14:22:54.000000000 -0400
-+++ src/gcc/config.gcc	2003-07-14 14:13:22.000000000 -0400
-@@ -554,7 +554,7 @@
- 	;;
- alpha*-*-linux*)
- 	tm_file="${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h"
--	target_cpu_default="MASK_GAS"
-+	target_cpu_default="MASK_GAS|MASK_IEEE_CONFORMANT|MASK_IEEE"
- 	tmake_file="t-slibgcc-elf-ver t-linux alpha/t-crtfm alpha/t-alpha alpha/t-ieee"
- 	;;
- alpha*-*-gnu*)
---- src/gcc/config/alpha/alpha.h.orig	2003-07-14 14:10:01.000000000 -0400
-+++ src/gcc/config/alpha/alpha.h	2003-07-14 14:12:55.000000000 -0400
-@@ -294,6 +294,8 @@
-      N_("Request IEEE-conformant math library routines (OSF/1)")},	\
-     {"ieee", MASK_IEEE|MASK_IEEE_CONFORMANT,				\
-      N_("Emit IEEE-conformant code, without inexact exceptions")},	\
-+    {"no-ieee", -(MASK_IEEE|MASK_IEEE_CONFORMANT),			\
-+     N_("Emit IEEE-nonconformant code (reverses -mieee)")},		\
-     {"ieee-with-inexact", MASK_IEEE_WITH_INEXACT|MASK_IEEE_CONFORMANT,	\
-      N_("Emit IEEE-conformant code, with inexact exceptions")},		\
-     {"build-constants", MASK_BUILD_CONSTANTS,				\
---- src/gcc/doc/invoke.texi.orig	2003-07-14 14:25:46.000000000 -0400
-+++ src/gcc/doc/invoke.texi	2003-07-14 15:22:28.000000000 -0400
-@@ -521,7 +521,7 @@
- 
- @emph{DEC Alpha Options}
- @gccoptlist{-mno-fp-regs  -msoft-float  -malpha-as  -mgas @gol
---mieee  -mieee-with-inexact  -mieee-conformant @gol
-+-mieee  -mno-ieee  -mieee-with-inexact  -mieee-conformant @gol
- -mfp-trap-mode=@var{mode}  -mfp-rounding-mode=@var{mode} @gol
- -mtrap-precision=@var{mode}  -mbuild-constants @gol
- -mcpu=@var{cpu-type}  -mtune=@var{cpu-type} @gol
-@@ -8917,7 +8917,9 @@
- and hence need not save and restore, any floating-point registers.
- 
- @item -mieee
-+@itemx -mno-ieee
- @opindex mieee
-+@opindex mno-ieee
- The Alpha architecture implements floating-point hardware optimized for
- maximum performance.  It is mostly compliant with the IEEE floating
- point standard.  However, for full compliance, software assistance is
-@@ -8929,6 +8931,12 @@
- values such as not-a-number and plus/minus infinity.  Other Alpha
+--- src/gcc/config/alpha/alpha.c_	2003-12-23 15:08:11.000000000 -0500
++++ src/gcc/config/alpha/alpha.c	2003-12-23 15:16:31.000000000 -0500
+@@ -337,4 +337,8 @@
+   };
+                   
++  /* If not -ffinite-math-only, enable -mieee*/
++  if (!flag_finite_math_only)
++    target_flags |= MASK_IEEE|MASK_IEEE_CONFORMANT;
++
+   /* Unicos/Mk doesn't have shared libraries.  */
+   if (TARGET_ABI_UNICOSMK && flag_pic)
+--- src/gcc/doc/invoke.texi_	2004-01-06 10:59:19.000000000 -0500
++++ src/gcc/doc/invoke.texi	2004-01-06 11:26:11.000000000 -0500
+@@ -8571,4 +8571,11 @@
  compilers call this option @option{-ieee_with_no_inexact}.
  
-+Under Debian GNU/Linux, @option{-mieee} is turned on by default, because the
-+functions implemented in software in the GCC math libraries conform to
-+the IEEE specification (i.e. they generate denormalized numbers, and
-+such, which will causes the program to SIGFPE when it attempts to use
-+the results in the FPU, if @option{-mieee} has not be specified).
++DEBIAN SPECIFIC: This option is on by default, unless
++@option{-ffinite-math-only} (which is part of the @option{-ffast-math}
++set) is specified, because the software functions in the GCC math
++libraries generate denormalized numbers, NaNs, and infs (all of which
++will cause a programs to SIGFPE when it attempts to use the results without
++@option{-mieee}).
 +
  @item -mieee-with-inexact
  @opindex mieee-with-inexact
- This is like @option{-mieee} except the generated code also maintains
--- debian/rules.patch_	2004-01-06 11:37:21.000000000 -0500
+++ debian/rules.patch	2004-01-06 11:37:36.000000000 -0500
@@ -72,5 +72,5 @@
 
 ifeq ($(DEB_TARGET_ARCH),alpha)
-  debian_patches +=
+  debian_patches += alpha-ieee
 endif
 ifeq ($(DEB_TARGET_ARCH),arm)

Reply to: