]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2010-05-25 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 May 2010 09:43:59 +0000 (09:43 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 May 2010 09:43:59 +0000 (09:43 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159815 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/opts.c
gcc/target-def.h
gcc/target.h

index 0546d7218354aaa4abf99f135aa7e6bee7fba09b..3ac6da341543921e13a0c315bbcede0d74c27602 100644 (file)
@@ -1,3 +1,13 @@
+2010-05-25  Richard Guenther  <rguenther@suse.de>
+
+       * 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  <bonzini@gnu.org>
 
        * doc/tm.texi (STORE_FLAG_VALUE): Do not refer to sCC patterns.
index 6c2ca93cfe6a5d21a2b58107f89285ad80eaa001..49044815509da641b2e04e6a120c5a8078906dc4 100644 (file)
@@ -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
index dbde14d22069d2339cd01337bc5c10d857e424ae..e9b3eab1f335cbebeb99fe1919545800f63d9db2 100644 (file)
@@ -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
index 329f732f7d2848c9c6602eaf0c25f0a3c0a3d4bd..2e788d28fddb1ffbb345284a55ad414f64c45007 100644 (file)
@@ -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);
 
index 09da722b8d9a217e7badea9d1e6832c25e527ad2..4db3997ad114565d2163481f23eb7c2c615269b4 100644 (file)
 #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 */
   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,                \
index 744790061a2f381fbdd1a1a041b30a10e898b4d2..6f045da12996bb66783d884c12dc978361a47e9e 100644 (file)
@@ -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);