This is the mail archive of the gcc-bugs@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]

Re: optimization/8092: cross-jump triggers too often


On Saturday 05 October 2002 11:57, Anton Ertl wrote:
> 1) Add a -fno-cross-jump flag or similar, as in Bernd's patch.

I had a closer look to the cross-jump code, and it does indeed add a crossjump 
to every single equivalent insn it finds (which is stupid - jumps are more 
expensive than single instructions). I added another flag as experiment, 
-fcross-jump-min=<n>, which eliminates cross-jumps for less than n insns. 
However, due to the way the crossjump search works, this increases compile 
time by quite a lot, due to the O(nē) order of the crossjump comparison 
algorithm. It's probably cheaper to first do the crossjump optimization, and 
then to clean up those that weren't cost-efficient (tail-duplication).

And tell me how cross-jump is a performance optimization. I can only see it as 
possible size optimization, but these should only be turned on with -Os.

--- gcc-3.2/gcc/cfgcleanup.c.orig	2002-10-05 22:15:17.000000000 +0200
+++ gcc-3.2/gcc/cfgcleanup.c	2002-10-05 22:16:45.000000000 +0200
@@ -1278,6 +1278,7 @@
      edge e1, e2;
 {
   int nmatch;
+  extern int cross_jump_min;
   basic_block src1 = e1->src, src2 = e2->src;
   basic_block redirect_to;
   rtx newpos1, newpos2;
@@ -1323,7 +1324,7 @@
 
   /* ... and part the second.  */
   nmatch = flow_find_cross_jump (mode, src1, src2, &newpos1, &newpos2);
-  if (!nmatch)
+  if (nmatch < cross_jump_min)
     return false;
 
   /* Avoid splitting if possible.  */
--- gcc-3.2/gcc/toplev.c.orig	2002-05-27 07:48:15.000000000 +0200
+++ gcc-3.2/gcc/toplev.c	2002-10-05 22:16:47.000000000 +0200
@@ -610,6 +610,11 @@
 
 int flag_syntax_only = 0;
 
+/* Nonzero means perform crossjump optimization. */
+
+static int flag_crossjump = 0;
+int cross_jump_min;
+
 /* Nonzero means perform global cse.  */
 
 static int flag_gcse;
@@ -1023,6 +1028,8 @@
    N_("Return 'short' aggregates in registers") },
   {"delayed-branch", &flag_delayed_branch, 1,
    N_("Attempt to fill delay slots of branch instructions") },
+  {"cross-jump", &flag_crossjump, 1,
+   N_("Perform crossjump optimization") },
   {"gcse", &flag_gcse, 1,
    N_("Perform the global common subexpression elimination") },
   {"gcse-lm", &flag_gcse_lm, 1,
@@ -3286,7 +3293,7 @@
   /* Cross-jumping is O(N^3) on the number of edges, thus trying to
      perform cross-jumping on flow graphs which have a high connectivity
      will take a long time.  This is similar to the test to disable GCSE.  */
-  cleanup_crossjump = CLEANUP_CROSSJUMP;
+  cleanup_crossjump = flag_crossjump ? CLEANUP_CROSSJUMP : 0;
   if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >= 20)
     {
       if (optimize && warn_disabled_optimization)
@@ -3907,6 +3914,8 @@
   else if ((option_value = skip_leading_substring (arg, "align-labels=")))
     align_labels
       = read_integral_parameter (option_value, arg - 2, align_labels);
+  else if ((option_value = skip_leading_substring (arg, "cross-jump-min=")))
+    cross_jump_min = read_integral_parameter (option_value, arg - 2, 
cross_jump_min);
   else if ((option_value
 	    = skip_leading_substring (arg, "stack-limit-register=")))
     {
@@ -4701,6 +4710,8 @@
       flag_optimize_sibling_calls = 1;
       flag_cse_follow_jumps = 1;
       flag_cse_skip_blocks = 1;
+      flag_crossjump = 1;
+      cross_jump_min = 1;
       flag_gcse = 1;
       flag_expensive_optimizations = 1;
       flag_strength_reduce = 1;
----------------------------------------------------------------------------

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/


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