[rfc] enable non-trivial complex division
Richard Henderson
rth@redhat.com
Sat Feb 19 18:32:00 GMT 2005
On Sat, Feb 12, 2005 at 12:15:24PM +0000, Joseph S. Myers wrote:
> > Now we must discuss when we want this new code enabled...
>
> Enabled by default. New option -fcx-limited-range, enabled by
> -ffast-math, to use naive algorithms.
I'm not sure that I agree that other languages want the, somewhat odd,
behaviour wrt nans and infinities. Certainly there doesn't seem to be
anything in the C++ or Fortran standards that specify this.
The worst part of this, IMO, being that C99 considers (+inf, nan) to
be an infinity and not a nan. This makes no sense to me.
Anyway, I've enabled the new library routine for C99, made everyone
else default to the more stable inline implementation. I do add the
new option described above for C, and for C allow -ffast-math to
change the default to the trivial inline implementation. I don't let
other languages change to the trivial inline implementation with
-fast-math, because of the lack of an option to change it back.
Comments?
r~
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.135
diff -u -p -d -r1.135 c-opts.c
--- c-opts.c 24 Jan 2005 11:59:40 -0000 1.135
+++ c-opts.c 19 Feb 2005 17:58:05 -0000
@@ -1028,6 +1028,17 @@ c_common_post_options (const char **pfil
return false;
}
+ /* With -fcx-limited-range, or with -ffast-math and with -fcx-limited-range
+ unspecified, or we do cheap and quick complex arithmetic. */
+ if (flag_cx_limited_range == 0
+ || (flag_unsafe_math_optimizations && flag_cx_limited_range < 0))
+ flag_complex_method = 0;
+
+ /* Otherwise, in C99 mode we must use the special routines that special
+ case the handling of infinities. */
+ else if (flag_isoc99)
+ flag_complex_method = 2;
+
if (flag_working_directory
&& flag_preprocess_only && !flag_no_line_commands)
pp_dir_change (parse_in, get_src_pwd ());
Index: c.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c.opt,v
retrieving revision 1.34
diff -u -p -d -r1.34 c.opt
--- c.opt 18 Jan 2005 06:03:45 -0000 1.34
+++ c.opt 19 Feb 2005 17:58:05 -0000
@@ -484,6 +484,10 @@ fconstant-string-class=
ObjC ObjC++ Joined
-fconst-string-class=<name> Use class <name> for constant strings
+fcx-limited-range
+C ObjC Var(flag_cx_limited_range) Init(-1)
+Enable pragma STDC CX_LIMITED_RANGE for the entire translation unit
+
fdefault-inline
C++ ObjC++
Inline member functions by default
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.942
diff -u -p -d -r1.942 toplev.c
--- toplev.c 12 Feb 2005 00:26:52 -0000 1.942
+++ toplev.c 19 Feb 2005 17:58:05 -0000
@@ -269,7 +269,7 @@ int flag_pcc_struct_return = DEFAULT_PCC
1 means wide ranges of inputs must work for complex divide.
2 means C99-like requirements for complex multiply and divide. */
-int flag_complex_method = 0;
+int flag_complex_method = 1;
/* Nonzero means that we don't want inlining by virtue of -fno-inline,
not just because the tree inliner turned us off. */
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.581
diff -u -p -d -r1.581 invoke.texi
--- doc/invoke.texi 19 Feb 2005 11:44:01 -0000 1.581
+++ doc/invoke.texi 19 Feb 2005 18:10:23 -0000
@@ -166,7 +166,7 @@ in the following sections.
-trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
-fallow-single-precision -fcond-mismatch @gol
-fsigned-bitfields -fsigned-char @gol
--funsigned-bitfields -funsigned-char}
+-funsigned-bitfields -funsigned-char -fcx-limited-range}
@item C++ Language Options
@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
@@ -1307,6 +1307,14 @@ These options control whether a bit-fiel
declaration does not use either @code{signed} or @code{unsigned}. By
default, such a bit-field is signed, because this is consistent: the
basic integer types such as @code{int} are signed types.
+
+@item -fcx-limited-range
+@itemx -fno-cx-limited-range
+@opindex fcx-limited-range
+@opindex fno-cx-limited-range
+These options control the default setting of the ISO C99
+@code{CX_LIMITED_RANGE} pragma. By default, @code{CX_LIMITED_RANGE} is
+off, though this is affected by @option{-ffast-math}.
@end table
@node C++ Dialect Options
@@ -5073,6 +5081,7 @@ them to store all pertinent intermediate
Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @*
@option{-fno-trapping-math}, @option{-ffinite-math-only},
@option{-fno-rounding-math} and @option{-fno-signaling-nans}.
+In C, this option sets @option{fcx-limited-range}.
This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
More information about the Fortran
mailing list