This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
enable non-trivial complex division, take 2
On Sat, Feb 19, 2005 at 08:11:22PM +0000, Joseph S. Myers wrote:
> That
> suggests for now having -fcx-limited-range as a language-independent flag,
> included in -ffast-math for all languages, which switches from the default
> of 1 (2 for C99) to 0 (and -ffast-math -fno-cx-limited-range keeping the
> default of 1 or 2) with C99 only changing the default from 1 to 2; and in
> future adding logarithmic reduction for both 1 and 2.
Done.
r~
PR middle-end/18902
* c-opts.c (c_common_post_options): Set flag_complex_method to 2
for c99.
* common.opt (fcx-limited-range): New.
* opts.c (set_fast_math_flags): Set flag_cx_limited_range.
* toplev.c (flag_complex_method): Initialize to 1.
(process_options): Set flag_complex_method to 0 if
flag_cx_limited_range.
* doc/invoke.texi (-fcx-limited-range): New.
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 24 Feb 2005 09:20:47 -0000
@@ -978,6 +978,11 @@ c_common_post_options (const char **pfil
if (warn_missing_format_attribute && !warn_format)
warning ("-Wmissing-format-attribute ignored without -Wformat");
+ /* C99 requires special handling of complex multiplication and division;
+ -ffast-math and -fcx-limited-range are handled in process_options. */
+ if (flag_isoc99)
+ flag_complex_method = 2;
+
if (flag_preprocess_only)
{
/* Open the output now. We must do so even if flag_no_output is
Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.61
diff -u -p -d -r1.61 common.opt
--- common.opt 7 Feb 2005 10:06:52 -0000 1.61
+++ common.opt 24 Feb 2005 09:20:47 -0000
@@ -310,6 +310,10 @@ fcse-skip-blocks
Common Report Var(flag_cse_skip_blocks)
When running CSE, follow conditional jumps
+fcx-limited-range
+Common Report Var(flag_cx_limited_range)
+Omit range reduction step when performing complex division
+
fdata-sections
Common Report Var(flag_data_sections)
Place data items into their own section
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.93
diff -u -p -d -r1.93 opts.c
--- opts.c 7 Feb 2005 10:06:52 -0000 1.93
+++ opts.c 24 Feb 2005 09:20:47 -0000
@@ -1097,6 +1097,7 @@ set_fast_math_flags (int set)
{
flag_signaling_nans = 0;
flag_rounding_math = 0;
+ flag_cx_limited_range = 1;
}
}
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.943
diff -u -p -d -r1.943 toplev.c
--- toplev.c 23 Feb 2005 01:35:07 -0000 1.943
+++ toplev.c 24 Feb 2005 09:20:48 -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. */
@@ -1948,6 +1948,10 @@ process_options (void)
/* The presence of IEEE signaling NaNs, implies all math can trap. */
if (flag_signaling_nans)
flag_trapping_math = 1;
+
+ /* With -fcx-limited-range, we do cheap and quick complex arithmetic. */
+ if (flag_cx_limited_range)
+ flag_complex_method = 0;
}
/* Initialize the compiler back end. */
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.582
diff -u -p -d -r1.582 invoke.texi
--- doc/invoke.texi 22 Feb 2005 23:38:02 -0000 1.582
+++ doc/invoke.texi 24 Feb 2005 09:20:51 -0000
@@ -285,8 +285,8 @@ Objective-C and Objective-C++ Dialects}.
-fbounds-check -fmudflap -fmudflapth -fmudflapir @gol
-fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
-fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
--fcaller-saves -fcprop-registers @gol
--fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol
+-fcaller-saves -fcprop-registers -fcse-follow-jumps @gol
+-fcse-follow-jumps -fcse-skip-blocks -fcx-limited-range -fdata-sections @gol
-fdelayed-branch -fdelete-null-pointer-checks @gol
-fexpensive-optimizations -ffast-math -ffloat-store @gol
-fforce-addr -fforce-mem -ffunction-sections @gol
@@ -5072,7 +5072,8 @@ them to store all pertinent intermediate
@opindex ffast-math
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}.
+@option{-fno-rounding-math}, @option{-fno-signaling-nans}
+and @option{fcx-limited-range}.
This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
@@ -5176,6 +5177,17 @@ disable all GCC optimizations that affec
Treat floating point constant as single precision constant instead of
implicitly converting it to double precision constant.
+@item -fcx-limited-range
+@itemx -fno-cx-limited-range
+@opindex fcx-limited-range
+@opindex fno-cx-limited-range
+When enabled, this option states that a range reduction step is not
+needed when performing complex division. The default is
+@option{-fno-cx-limited-range}, but is enabled by @option{-ffast-math}.
+
+This option controls the default setting of the ISO C99
+@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
+all languages.
@end table