From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26833 invoked by alias); 5 Oct 2002 21:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 26819 invoked by uid 71); 5 Oct 2002 21:36:00 -0000 Date: Sat, 05 Oct 2002 14:36:00 -0000 Message-ID: <20021005213600.26818.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Bernd Paysan Subject: Re: optimization/8092: cross-jump triggers too often Reply-To: Bernd Paysan X-SW-Source: 2002-10/txt/msg00203.txt.bz2 List-Id: The following reply was made to PR optimization/8092; it has been noted by GNATS. From: Bernd Paysan To: anton@mips.complang.tuwien.ac.at, Anton Ertl , rth@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, obody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Cc: Subject: Re: optimization/8092: cross-jump triggers too often Date: Sat, 5 Oct 2002 22:44:35 +0200 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 cros= sjump=20 to every single equivalent insn it finds (which is stupid - jumps are mor= e=20 expensive than single instructions). I added another flag as experiment,=20 -fcross-jump-min=3D, which eliminates cross-jumps for less than n insn= s.=20 However, due to the way the crossjump search works, this increases compil= e=20 time by quite a lot, due to the O(n=B2) order of the crossjump comparison= =20 algorithm. It's probably cheaper to first do the crossjump optimization, = and=20 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=20 possible size optimization, but these should only be turned on with -Os. --- gcc-3.2/gcc/cfgcleanup.c.orig=092002-10-05 22:15:17.000000000 +0200 +++ gcc-3.2/gcc/cfgcleanup.c=092002-10-05 22:16:45.000000000 +0200 @@ -1278,6 +1278,7 @@ edge e1, e2; { int nmatch; + extern int cross_jump_min; basic_block src1 =3D e1->src, src2 =3D e2->src; basic_block redirect_to; rtx newpos1, newpos2; @@ -1323,7 +1324,7 @@ =20 /* ... and part the second. */ nmatch =3D flow_find_cross_jump (mode, src1, src2, &newpos1, &newpos2)= ; - if (!nmatch) + if (nmatch < cross_jump_min) return false; =20 /* Avoid splitting if possible. */ --- gcc-3.2/gcc/toplev.c.orig=092002-05-27 07:48:15.000000000 +0200 +++ gcc-3.2/gcc/toplev.c=092002-10-05 22:16:47.000000000 +0200 @@ -610,6 +610,11 @@ =20 int flag_syntax_only =3D 0; =20 +/* Nonzero means perform crossjump optimization. */ + +static int flag_crossjump =3D 0; +int cross_jump_min; + /* Nonzero means perform global cse. */ =20 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= =2E */ - cleanup_crossjump =3D CLEANUP_CROSSJUMP; + cleanup_crossjump =3D flag_crossjump ? CLEANUP_CROSSJUMP : 0; if (n_basic_blocks > 1000 && n_edges / n_basic_blocks >=3D 20) { if (optimize && warn_disabled_optimization) @@ -3907,6 +3914,8 @@ else if ((option_value =3D skip_leading_substring (arg, "align-labels=3D= "))) align_labels =3D read_integral_parameter (option_value, arg - 2, align_labels); + else if ((option_value =3D skip_leading_substring (arg, "cross-jump-mi= n=3D"))) + cross_jump_min =3D read_integral_parameter (option_value, arg - 2,=20 cross_jump_min); else if ((option_value =09 =3D skip_leading_substring (arg, "stack-limit-register=3D"))) { @@ -4701,6 +4710,8 @@ flag_optimize_sibling_calls =3D 1; flag_cse_follow_jumps =3D 1; flag_cse_skip_blocks =3D 1; + flag_crossjump =3D 1; + cross_jump_min =3D 1; flag_gcse =3D 1; flag_expensive_optimizations =3D 1; flag_strength_reduce =3D 1; -------------------------------------------------------------------------= --- --=20 Bernd Paysan "If you want it done right, you have to do it yourself" http://www.jwdt.com/~paysan/