diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0546d721835..3ac6da34154 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2010-05-25 Richard Guenther + + * doc/invoke.texi: Document -Ofast. + * target.h (struct gcc_target): Add handle_ofast. + * target-def.h (TARGET_HANDLE_OFAST): Add. + (TARGET_INITIALIZER): Adjust. + * opts.c (decode_options): Handle -Ofast. Enable + -ffast-math with it. + * common.opt (Ofast): Add. + 2010-05-25 Paolo Bonzini * doc/tm.texi (STORE_FLAG_VALUE): Do not refer to sCC patterns. diff --git a/gcc/common.opt b/gcc/common.opt index 6c2ca93cfe6..49044815509 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -69,6 +69,10 @@ Os Common Optimization Optimize for space rather than speed +Ofast +Common Optimization +Optimize for speed disregarding exact standards compliance + W Common RejectNegative Var(extra_warnings) Warning This switch is deprecated; use -Wextra instead diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index dbde14d2206..e9b3eab1f33 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -393,7 +393,7 @@ Objective-C and Objective-C++ Dialects}. -fvariable-expansion-in-unroller -fvect-cost-model -fvpt -fweb @gol -fwhole-program -fwhopr[=@var{n}] -fwpa -fuse-linker-plugin @gol --param @var{name}=@var{value} --O -O0 -O1 -O2 -O3 -Os} +-O -O0 -O1 -O2 -O3 -Os -Ofast} @item Preprocessor Options @xref{Preprocessor Options,,Options Controlling the Preprocessor}. @@ -5891,6 +5891,13 @@ optimizations designed to reduce code size. -falign-labels -freorder-blocks -freorder-blocks-and-partition @gol -fprefetch-loop-arrays -ftree-vect-loop-version} +@item -Ofast +@opindex Ofast +Disregard strict standards compliance. @option{-Ofast} enables all +@option{-O3} optimizations. It also enables optimizations that are not +valid for all standard compliant programs. +It turns on @option{-ffast-math}. + If you use multiple @option{-O} options, with or without level numbers, the last such option is the one that is effective. @end table diff --git a/gcc/opts.c b/gcc/opts.c index 329f732f7d2..2e788d28fdd 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -63,7 +63,7 @@ bool warn_larger_than; HOST_WIDE_INT larger_than_size; /* True to warn about any function whose frame size is larger - * than N bytes. */ + than N bytes. */ bool warn_frame_larger_than; HOST_WIDE_INT frame_larger_than_size; @@ -804,6 +804,7 @@ decode_options (unsigned int argc, const char **argv) int opt2; int opt3; int opt1_max; + int ofast = 0; if (first_time_p) { @@ -831,6 +832,7 @@ decode_options (unsigned int argc, const char **argv) { optimize = 1; optimize_size = 0; + ofast = 0; } else if (argv[i][0] == '-' && argv[i][1] == 'O') { @@ -843,6 +845,14 @@ decode_options (unsigned int argc, const char **argv) /* Optimizing for size forces optimize to be 2. */ optimize = 2; + ofast = 0; + } + else if (strcmp (p, "fast") == 0) + { + /* -Ofast only adds flags to -O3. */ + optimize_size = 0; + optimize = 3; + ofast = 1; } else { @@ -853,6 +863,7 @@ decode_options (unsigned int argc, const char **argv) if ((unsigned int) optimize > 255) optimize = 255; optimize_size = 0; + ofast = 0; } } } @@ -967,6 +978,17 @@ decode_options (unsigned int argc, const char **argv) else set_param_value ("min-crossjump-insns", initial_min_crossjump_insns); + /* -Ofast adds optimizations to -O3. */ + if (ofast) + { + /* Which is -ffast-math for now. */ + set_fast_math_flags (1); + /* Allow targets to enable extra options with -Ofast + before general options processing so disabling them + again afterwards works. */ + targetm.handle_ofast (); + } + /* Enable -Werror=coverage-mismatch by default */ enable_warning_as_error("coverage-mismatch", 1, lang_mask); diff --git a/gcc/target-def.h b/gcc/target-def.h index 09da722b8d9..4db3997ad11 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -431,6 +431,7 @@ #define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook_void_void #define TARGET_HANDLE_OPTION hook_bool_size_t_constcharptr_int_true +#define TARGET_HANDLE_OFAST hook_void_void #define TARGET_HELP NULL /* In except.c */ @@ -939,6 +940,7 @@ TARGET_DEFAULT_TARGET_FLAGS, \ TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE, \ TARGET_HANDLE_OPTION, \ + TARGET_HANDLE_OFAST, \ TARGET_HELP, \ TARGET_EH_RETURN_FILTER_MODE, \ TARGET_LIBGCC_CMP_RETURN_MODE, \ diff --git a/gcc/target.h b/gcc/target.h index 744790061a2..6f045da1299 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -531,6 +531,9 @@ struct gcc_target form was. Return true if the switch was valid. */ bool (* handle_option) (size_t code, const char *arg, int value); + /* Handle target-specific parts of specifying -Ofast. */ + void (* handle_ofast) (void); + /* Display extra, target specific information in response to a --target-help switch. */ void (* target_help) (void);