[PATCH] Limit path splitting to loops we optimize for speed
authorJeff Law <law@redhat.com>
Thu, 17 Dec 2015 23:33:44 +0000 (16:33 -0700)
committerJeff Law <law@gcc.gnu.org>
Thu, 17 Dec 2015 23:33:44 +0000 (16:33 -0700)
* doc/invoke.texi (-O2 options): Remove -fsplit-paths.
(-O3 options): Add -fsplit-paths.
* gimple-ssa-split-paths.c: Include predict.h
(split_paths): Only split paths in a loop that should be
optimized for speed.
* opts.c (default_options_table): Move -fsplit-paths from -O2 to
-O3.

* gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path
splitting optimizations.

From-SVN: r231790

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/gimple-ssa-split-paths.c
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c

index a1f71bdfa865413714d8688c404859dfb809a546..070b2dd5c0b938b79403db5dde3e20124f51b10b 100644 (file)
@@ -1,3 +1,13 @@
+2015-12-17  Jeff Law  <law@redhat.com>
+
+       * doc/invoke.texi (-O2 options): Remove -fsplit-paths.
+       (-O3 options): Add -fsplit-paths.
+       * gimple-ssa-split-paths.c: Include predict.h
+       (split_paths): Only split paths in a loop that should be
+       optimized for speed.
+       * opts.c (default_options_table): Move -fsplit-paths from -O2 to
+       -O3.
+
 2015-12-17  Nathan Sidwell  <nathan@acm.org>
 
        * ipa-icf.c (sem_item_optimizer::merge): Don't pick 'main' as the
index cdc5d2c4e19d475a772cdee324815b3a3b28a198..60530c0464a0832a93be14418554a1485cab7cb6 100644 (file)
@@ -7836,7 +7836,6 @@ also turns on the following optimization flags:
 -frerun-cse-after-loop  @gol
 -fsched-interblock  -fsched-spec @gol
 -fschedule-insns  -fschedule-insns2 @gol
--fsplit-paths @gol
 -fstrict-aliasing -fstrict-overflow @gol
 -ftree-builtin-call-dce @gol
 -ftree-switch-conversion -ftree-tail-merge @gol
@@ -7853,7 +7852,7 @@ Optimize yet more.  @option{-O3} turns on all optimizations specified
 by @option{-O2} and also turns on the @option{-finline-functions},
 @option{-funswitch-loops}, @option{-fpredictive-commoning},
 @option{-fgcse-after-reload}, @option{-ftree-loop-vectorize},
-@option{-ftree-loop-distribute-patterns},
+@option{-ftree-loop-distribute-patterns}, @option{-fsplit-paths}
 @option{-ftree-slp-vectorize}, @option{-fvect-cost-model},
 @option{-ftree-partial-pre} and @option{-fipa-cp-clone} options.
 
index 602e916f88ede1a4dfa17a9761e99917d641a107..540fdf3c33aae43da20e0ac9d398a47937e0b028 100644 (file)
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "gimple-iterator.h"
 #include "tracer.h"
+#include "predict.h"
 
 /* Given LATCH, the latch block in a loop, see if the shape of the
    path reaching LATCH is suitable for being split by duplication.
@@ -180,9 +181,14 @@ split_paths ()
 
   FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
     {
+      /* Only split paths if we are optimizing this loop for speed.  */
+      if (!optimize_loop_for_speed_p (loop))
+       continue;
+
       /* See if there is a block that we can duplicate to split the
         path to the loop latch.  */
-      basic_block bb = find_block_to_duplicate_for_splitting_paths (loop->latch);
+      basic_block bb
+       = find_block_to_duplicate_for_splitting_paths (loop->latch);
 
       /* BB is the merge point for an IF-THEN-ELSE we want to transform.
 
index d46f304d26229da08923d9f515c74d71fb30fafc..7ab585f1e5385cc68603aaac015cc2d531b4df31 100644 (file)
@@ -523,11 +523,11 @@ static const struct default_options default_options_table[] =
     { OPT_LEVELS_2_PLUS, OPT_fisolate_erroneous_paths_dereference, NULL, 1 },
     { OPT_LEVELS_2_PLUS, OPT_fipa_ra, NULL, 1 },
     { OPT_LEVELS_2_PLUS, OPT_flra_remat, NULL, 1 },
-    { OPT_LEVELS_2_PLUS, OPT_fsplit_paths, NULL, 1 },
 
     /* -O3 optimizations.  */
     { OPT_LEVELS_3_PLUS, OPT_ftree_loop_distribute_patterns, NULL, 1 },
     { OPT_LEVELS_3_PLUS, OPT_fpredictive_commoning, NULL, 1 },
+    { OPT_LEVELS_3_PLUS, OPT_fsplit_paths, NULL, 1 },
     /* Inlining of functions reducing size is a good idea with -Os
        regardless of them being declared inline.  */
     { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 },
index d5ae29900974d00a8464851130cbe3991081ee3d..baa159d381104eaf5a38bb0f910bb26f3f3a9c85 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-17  Jeff Law  <law@redhat.com>
+
+       * gcc.dg/tree-ssa/split-path-1.c: Explicitly ask for path
+       splitting optimizations.
+
 2015-12-17  Nathan Sidwell  <nathan@acm.org>
 
        * gcc.dg/ipa/ipa-icf-merge-1.c: New.
index 5c96241aa0ce1a3cbe9c5bc2561cc7c551c7d616..b24f6a9f79e790590a6295ab9389e8153863e8ab 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -fdump-tree-split-paths-details " } */
+/* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details " } */
 
 #include <stdio.h>
 #include <stdlib.h>