This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR middle-end/17278


Hi,

The attached patch turns off some of the more expensive optimizations
for -O1.  Since the tree-ssa merge, we have been running all tree-ssa
passes, full blown, even at -O1.  Obviously this can be costly.  OTOH
the tree-ssa passes are relatively cheap, so I wouldn't want to turn
off that many.  Finding RTL passes to turn off is much harder because
unfortunately they still do a lot of very useful transformations.

So, with this patch I've just turned off things that I've found to be
not too useful for the resulting code.  RTL jump threading is mostly
subsumed by DOM.  DOM now iterates, but it usually does not find many
new optimizations to do in the next runs.  And, we run the pass three
times anyway.  Finally, GCSE was never enabled at -O1, and GVN-PRE is
not exactly cheap for some tests.  For the test case of the PR, ir.cc
from Mico ORB:

 tree PRE  :   0.75 ( 2%) usr   0.01 ( 0%) sys   0.66 ( 2%) wall

I have run this through SPECint2k and compared the -O1 scores of gcc4
patched with gcc4 unpatched.  The scores are the about the same (-0.2%
with the patch) but the compiler is 5% faster.  For the test case from
the PR (ir.cc) we are 4% faster with the patch.

OK for mainline?

Gr.
Steven

	* opts.c (decode_options): Move flag_thread_jumps from -O1 and
	higher to -O2 and higher.  Likewise for tree PRE.
	* tree-ssa-dom.c (tree_ssa_dominator_optimize): Only iterate at -O2
	and better.

Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.90
diff -u -3 -p -r1.90 opts.c
--- opts.c	29 Nov 2004 09:33:08 -0000	1.90
+++ opts.c	21 Jan 2005 10:41:38 -0000
@@ -481,7 +481,6 @@ decode_options (unsigned int argc, const
   if (optimize >= 1)
     {
       flag_defer_pop = 1;
-      flag_thread_jumps = 1;
 #ifdef DELAY_SLOTS
       flag_delayed_branch = 1;
 #endif
@@ -510,14 +509,12 @@ decode_options (unsigned int argc, const
 	     the condition is satisfied in the first iteration and therefore
 	     to eliminate it.  Jump threading handles these cases now.  */
 	  flag_tree_ch = 1;
- 
-          /* PRE tends to generate bigger code.  */
-          flag_tree_pre = 1;
 	}
     }
 
   if (optimize >= 2)
     {
+      flag_thread_jumps = 1;
       flag_crossjumping = 1;
       flag_optimize_sibling_calls = 1;
       flag_cse_follow_jumps = 1;
@@ -540,6 +537,12 @@ decode_options (unsigned int argc, const
       flag_reorder_blocks = 1;
       flag_reorder_functions = 1;
       flag_unit_at_a_time = 1;
+
+      if (!optimize_size)
+	{
+          /* PRE tends to generate bigger code.  */
+          flag_tree_pre = 1;
+	}
     }
 
   if (optimize >= 3)
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.86
diff -u -3 -p -r2.86 tree-ssa-dom.c
--- tree-ssa-dom.c	18 Jan 2005 04:38:59 -0000	2.86
+++ tree-ssa-dom.c	21 Jan 2005 10:41:38 -0000
@@ -479,7 +479,7 @@ tree_ssa_dominator_optimize (void)
 	    SSA_NAME_VALUE (name) = NULL;
 	}
     }
-  while (cfg_altered);
+  while (optimize > 1 && cfg_altered);
 
   /* Debugging dumps.  */
   if (dump_file && (dump_flags & TDF_STATS))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]