Revert: "Fix -ffast-math flags handling inconsistencies"
This reverts commit c4fa3728ab
,
which caused a regression in the default for flag_excess_precision.
2020-11-24 Ulrich Weigand <uweigand@de.ibm.com>
gcc/
PR tree-optimization/97970
* doc/invoke.texi (-ffast-math): Revert last change.
* opts.c: Revert last change.
This commit is contained in:
parent
1805dbc58b
commit
ce2d9549f2
@ -12342,10 +12342,10 @@ 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{-fcx-limited-range} and @option{-fexcess-precision=fast}.
|
||||
@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
|
||||
@option{-fexcess-precision=fast}.
|
||||
|
||||
Whenever all these options listed above are set to those values,
|
||||
the preprocessor macro @code{__FAST_MATH__} will be defined.
|
||||
This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
|
||||
|
||||
This option is not turned on by any @option{-O} option besides
|
||||
@option{-Ofast} since it can result in incorrect output for programs
|
||||
|
58
gcc/opts.c
58
gcc/opts.c
@ -193,12 +193,10 @@ static void set_debug_level (enum debug_info_type type, int extended,
|
||||
const char *arg, struct gcc_options *opts,
|
||||
struct gcc_options *opts_set,
|
||||
location_t loc);
|
||||
static void set_fast_math_flags (struct gcc_options *opts,
|
||||
struct gcc_options *opts_set, int set);
|
||||
static void set_fast_math_flags (struct gcc_options *opts, int set);
|
||||
static void decode_d_option (const char *arg, struct gcc_options *opts,
|
||||
location_t loc, diagnostic_context *dc);
|
||||
static void set_unsafe_math_optimizations_flags (struct gcc_options *opts,
|
||||
struct gcc_options *opts_set,
|
||||
int set);
|
||||
static void enable_warning_as_error (const char *arg, int value,
|
||||
unsigned int lang_mask,
|
||||
@ -2493,11 +2491,11 @@ common_handle_option (struct gcc_options *opts,
|
||||
break;
|
||||
|
||||
case OPT_ffast_math:
|
||||
set_fast_math_flags (opts, opts_set, value);
|
||||
set_fast_math_flags (opts, value);
|
||||
break;
|
||||
|
||||
case OPT_funsafe_math_optimizations:
|
||||
set_unsafe_math_optimizations_flags (opts, opts_set, value);
|
||||
set_unsafe_math_optimizations_flags (opts, value);
|
||||
break;
|
||||
|
||||
case OPT_ffixed_:
|
||||
@ -2878,44 +2876,44 @@ set_Wstrict_aliasing (struct gcc_options *opts, int onoff)
|
||||
/* The following routines are useful in setting all the flags that
|
||||
-ffast-math and -fno-fast-math imply. */
|
||||
static void
|
||||
set_fast_math_flags (struct gcc_options *opts,
|
||||
struct gcc_options *opts_set, int set)
|
||||
set_fast_math_flags (struct gcc_options *opts, int set)
|
||||
{
|
||||
if (!opts->frontend_set_flag_unsafe_math_optimizations
|
||||
&& !opts_set->x_flag_unsafe_math_optimizations)
|
||||
if (!opts->frontend_set_flag_unsafe_math_optimizations)
|
||||
{
|
||||
opts->x_flag_unsafe_math_optimizations = set;
|
||||
set_unsafe_math_optimizations_flags (opts, opts_set, set);
|
||||
set_unsafe_math_optimizations_flags (opts, set);
|
||||
}
|
||||
if (!opts->frontend_set_flag_finite_math_only)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_finite_math_only, set);
|
||||
opts->x_flag_finite_math_only = set;
|
||||
if (!opts->frontend_set_flag_errno_math)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_errno_math, !set);
|
||||
if (!opts->frontend_set_flag_cx_limited_range)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_cx_limited_range, set);
|
||||
if (!opts->frontend_set_flag_excess_precision)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_excess_precision,
|
||||
set ? EXCESS_PRECISION_FAST
|
||||
: EXCESS_PRECISION_DEFAULT);
|
||||
|
||||
// -ffast-math should also reset -frounding-math, but since this
|
||||
// is off by default, there's nothing to do for now.
|
||||
opts->x_flag_errno_math = !set;
|
||||
if (set)
|
||||
{
|
||||
if (opts->frontend_set_flag_excess_precision == EXCESS_PRECISION_DEFAULT)
|
||||
opts->x_flag_excess_precision
|
||||
= 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)
|
||||
opts->x_flag_rounding_math = 0;
|
||||
if (!opts->frontend_set_flag_cx_limited_range)
|
||||
opts->x_flag_cx_limited_range = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* When -funsafe-math-optimizations is set the following
|
||||
flags are set as well. */
|
||||
static void
|
||||
set_unsafe_math_optimizations_flags (struct gcc_options *opts,
|
||||
struct gcc_options *opts_set, int set)
|
||||
set_unsafe_math_optimizations_flags (struct gcc_options *opts, int set)
|
||||
{
|
||||
if (!opts->frontend_set_flag_trapping_math)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_trapping_math, !set);
|
||||
opts->x_flag_trapping_math = !set;
|
||||
if (!opts->frontend_set_flag_signed_zeros)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_signed_zeros, !set);
|
||||
opts->x_flag_signed_zeros = !set;
|
||||
if (!opts->frontend_set_flag_associative_math)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_associative_math, set);
|
||||
opts->x_flag_associative_math = set;
|
||||
if (!opts->frontend_set_flag_reciprocal_math)
|
||||
SET_OPTION_IF_UNSET (opts, opts_set, flag_reciprocal_math, set);
|
||||
opts->x_flag_reciprocal_math = set;
|
||||
}
|
||||
|
||||
/* Return true iff flags in OPTS are set as if -ffast-math. */
|
||||
@ -2923,14 +2921,10 @@ bool
|
||||
fast_math_flags_set_p (const struct gcc_options *opts)
|
||||
{
|
||||
return (!opts->x_flag_trapping_math
|
||||
&& !opts->x_flag_signed_zeros
|
||||
&& opts->x_flag_associative_math
|
||||
&& opts->x_flag_reciprocal_math
|
||||
&& 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_rounding_math
|
||||
&& opts->x_flag_cx_limited_range
|
||||
&& opts->x_flag_excess_precision == EXCESS_PRECISION_FAST);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user