diff options
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/common.opt | 4 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 26 | ||||
-rw-r--r-- | gcc/flags.h | 7 | ||||
-rw-r--r-- | gcc/opts.c | 11 | ||||
-rw-r--r-- | gcc/toplev.c | 6 |
6 files changed, 60 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 10e6681aa26..91ad0d7299d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2003-09-03 Roger Sayle <roger@eyesopen.com> + + * toplev.c (flag_rounding_math): New global variable. + (f_options): Add to the list of language independent options. + * flags.h (flag_rounding_math): Prototype here. + (HONOR_SIGN_DEPENDENT_ROUNDING): Use flag_rounding_math instead. + * common.opt (frounding-math): New common command line option. + * opts.c (common_handle_option): Handle OPT_frounding_math. + (set_fast_math_flags): -ffast-math clears flag_rounding_math. + + * doc/invoke.texi: Document this new command line option. + 2003-09-03 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> * config/sol2.h (NO_IMPLICIT_EXTERN_C): Update comment. diff --git a/gcc/common.opt b/gcc/common.opt index 546e7388505..68c37b0c696 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -552,6 +552,10 @@ frerun-loop-opt Common Run the loop optimizer twice +frounding-math +Common +Disable optimizations that assume default FP rounding behavior + fsched-interblock Common Enable scheduling across basic blocks diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fb4cf782388..359e64fa608 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -280,7 +280,7 @@ in the following sections. -freduce-all-givs -fregmove -frename-registers @gol -freorder-blocks -freorder-functions @gol -frerun-cse-after-loop -frerun-loop-opt @gol --fschedule-insns -fschedule-insns2 @gol +-frounding-math -fschedule-insns -fschedule-insns2 @gol -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol -fsched-spec-load-dangerous -fsched2-use-superblocks @gol -fsched2-use-traces -fsignaling-nans @gol @@ -4260,8 +4260,8 @@ them to store all pertinent intermediate computations into variables. @item -ffast-math @opindex ffast-math Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, @* -@option{-fno-trapping-math}, @option{-ffinite-math-only} and @* -@option{-fno-signaling-nans}. +@option{-fno-trapping-math}, @option{-ffinite-math-only}, +@option{-fno-rounding-math} and @option{-fno-signaling-nans}. This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. @@ -4325,6 +4325,26 @@ math functions. The default is @option{-ftrapping-math}. +@item -frounding-math +@opindex frounding-math +Disable transformations and optimizations that assume default floating +point rounding behavior. This is round-to-zero for all floating point +to integer conversions, and round-to-nearest for all other arithmetic +truncations. This option should be specified for programs that change +the FP rounding mode dynamically, or that may be executed with a +non-default rounding mode. This option disables constant folding of +floating point expressions at compile-time (which may be affected by +rounding mode) and arithmetic transformations that are unsafe in the +presence of sign-dependent rounding modes. + +The default is @option{-fno-rounding-math}. + +This option is experimental and does not currently guarantee to +disable all GCC optimizations that are affected by rounding mode. +Future versions of gcc may provide finer control of this setting +using C99's @code{FENV_ACCESS} pragma. This command line option +will be used to specify the default state for @code{FENV_ACCESS}. + @item -fsignaling-nans @opindex fsignaling-nans Compile code assuming that IEEE signaling NaNs may generate user-visible diff --git a/gcc/flags.h b/gcc/flags.h index 6195fee365d..823aaefb32d 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -363,6 +363,11 @@ extern int flag_finite_math_only; extern int flag_trapping_math; +/* Nonzero means disable transformations that assume default floating + point rounding behavior. */ + +extern int flag_rounding_math; + /* 0 means straightforward implementation of complex divide acceptable. 1 means wide ranges of inputs must work for complex divide. 2 means C99-like requirements for complex divide (not yet implemented). */ @@ -716,6 +721,6 @@ extern const char *flag_random_seed; /* Like HONOR_NANS, but true if given mode supports sign-dependent rounding, and the rounding mode is important. */ #define HONOR_SIGN_DEPENDENT_ROUNDING(MODE) \ - (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && !flag_unsafe_math_optimizations) + (MODE_HAS_SIGN_DEPENDENT_ROUNDING (MODE) && flag_rounding_math) #endif /* ! GCC_FLAGS_H */ diff --git a/gcc/opts.c b/gcc/opts.c index 24741da5588..fe8d28f5604 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1220,8 +1220,12 @@ common_handle_option (size_t scode, const char *arg, flag_rerun_loop_opt = value; break; + case OPT_frounding_math: + flag_rounding_math = value; + break; + case OPT_fsched_interblock: - flag_schedule_interblock= value; + flag_schedule_interblock = value; break; case OPT_fsched_spec: @@ -1547,7 +1551,10 @@ set_fast_math_flags (int set) flag_finite_math_only = set; flag_errno_math = !set; if (set) - flag_signaling_nans = 0; + { + flag_signaling_nans = 0; + flag_rounding_math = 0; + } } /* Return true iff flags are set as if -ffast-math. */ diff --git a/gcc/toplev.c b/gcc/toplev.c index 3e639c6a151..b98538568e3 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -633,6 +633,11 @@ int flag_finite_math_only = 0; int flag_trapping_math = 1; +/* Nonzero means disable transformations that assume default floating + point rounding behavior. */ + +int flag_rounding_math = 0; + /* Nonzero means disable transformations observable by signaling NaNs. This option implies that any operation on an IEEE signaling NaN can generate a (user-visible) trap. */ @@ -1113,6 +1118,7 @@ static const lang_independent_options f_options[] = { "guess-branch-probability", &flag_guess_branch_prob, 1 }, {"math-errno", &flag_errno_math, 1 }, {"trapping-math", &flag_trapping_math, 1 }, + {"rounding-math", &flag_rounding_math, 1 }, {"unsafe-math-optimizations", &flag_unsafe_math_optimizations, 1 }, {"signaling-nans", &flag_signaling_nans, 1 }, {"bounds-check", &flag_bounds_check, 1 }, |