[Patch] Turn -fexcess-precision=fast on when in -ffast-math
authorJames Greenhalgh <james.greenhalgh@arm.com>
Tue, 20 Dec 2016 16:17:27 +0000 (16:17 +0000)
committerJames Greenhalgh <jgreenhalgh@gcc.gnu.org>
Tue, 20 Dec 2016 16:17:27 +0000 (16:17 +0000)
* common.opt (excess_precision): Tag as SetByCombined.
* opts.c (set_fast_math_flags): Also set
flag_excess_precision_cmdline.
(fast_math_flags_set_p): Also check flag_excess_precision_cmdline.
* doc/invoke.texi (-fexcess-precision): Drop text saying the
option has no effect under -ffast-math, make it clear that
-ffast-math will cause -fexcess-precision=fast by default even for
standards compliant modes.
(-ffast-math): Document that this sets -fexcess-precision=fast.

From-SVN: r243824

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/opts.c

index 6d22e948fe176925bc9b0102566c4ad17def61f7..156408f2f10f29628802cce00357b0bada6fc4b1 100644 (file)
@@ -1,3 +1,15 @@
+2016-12-20  James Greenhalgh  <james.greenhalghj@arm.com>
+
+       * common.opt (excess_precision): Tag as SetByCombined.
+       * opts.c (set_fast_math_flags): Also set
+       flag_excess_precision_cmdline.
+       (fast_math_flags_set_p): Also check flag_excess_precision_cmdline.
+       * doc/invoke.texi (-fexcess-precision): Drop text saying the
+       option has no effect under -ffast-math, make it clear that
+       -ffast-math will cause -fexcess-precision=fast by default even for
+       standards compliant modes.
+       (-ffast-math): Document that this sets -fexcess-precision=fast.
+
 2016-12-20  Richard Biener  <rguenther@suse.de>
 
        * passes.c (execute_one_pass): Handle going out of SSA w/o
index de068447d3119ab260cfbe86fe96452c050d9e7e..6ebaf9ca6728b7a00a2dc8fa35c3434bee3327fb 100644 (file)
@@ -1317,7 +1317,7 @@ Common Report Var(flag_expensive_optimizations) Optimization
 Perform a number of minor, expensive optimizations.
 
 fexcess-precision=
-Common Joined RejectNegative Enum(excess_precision) Var(flag_excess_precision_cmdline) Init(EXCESS_PRECISION_DEFAULT)
+Common Joined RejectNegative Enum(excess_precision) Var(flag_excess_precision_cmdline) Init(EXCESS_PRECISION_DEFAULT) SetByCombined
 -fexcess-precision=[fast|standard]     Specify handling of excess floating-point precision.
 
 Enum
index b72996488799be17e7371bc0cea8b2da3bcb192d..5c92fe69335cae0b5657bff37ac79f86cb88a906 100644 (file)
@@ -9109,12 +9109,12 @@ both casts and assignments cause values to be rounded to their
 semantic types (whereas @option{-ffloat-store} only affects
 assignments).  This option is enabled by default for C if a strict
 conformance option such as @option{-std=c99} is used.
+@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
+regardless of whether a strict conformance option is used.
 
 @opindex mfpmath
 @option{-fexcess-precision=standard} is not implemented for languages
-other than C, and has no effect if
-@option{-funsafe-math-optimizations} or @option{-ffast-math} is
-specified.  On the x86, it also has no effect if @option{-mfpmath=sse}
+other than C.  On the x86, it has no effect if @option{-mfpmath=sse}
 or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
 semantics apply without excess precision, and in the latter, rounding
 is unpredictable.
@@ -9123,7 +9123,8 @@ is unpredictable.
 @opindex ffast-math
 Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
 @option{-ffinite-math-only}, @option{-fno-rounding-math},
-@option{-fno-signaling-nans} and @option{-fcx-limited-range}.
+@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
+@option{-fexcess-precision=fast}.
 
 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
 
index 890da03e6a12d4eaadae8b21b96998ccf9a8ad74..58441908d110385381a5c78a26a50bd690917e2f 100644 (file)
@@ -2342,6 +2342,10 @@ set_fast_math_flags (struct gcc_options *opts, int set)
     opts->x_flag_errno_math = !set;
   if (set)
     {
+      if (opts->frontend_set_flag_excess_precision_cmdline
+         == EXCESS_PRECISION_DEFAULT)
+       opts->x_flag_excess_precision_cmdline
+         = set ? EXCESS_PRECISION_FAST : EXCESS_PRECISION_DEFAULT;
       if (!opts->frontend_set_flag_signaling_nans)
        opts->x_flag_signaling_nans = 0;
       if (!opts->frontend_set_flag_rounding_math)
@@ -2374,7 +2378,9 @@ fast_math_flags_set_p (const struct gcc_options *opts)
          && opts->x_flag_unsafe_math_optimizations
          && opts->x_flag_finite_math_only
          && !opts->x_flag_signed_zeros
-         && !opts->x_flag_errno_math);
+         && !opts->x_flag_errno_math
+         && opts->x_flag_excess_precision_cmdline
+            == EXCESS_PRECISION_FAST);
 }
 
 /* Return true iff flags are set as if -ffast-math but using the flags stored