[PATCH] Pass down branch probability through dojump.c functions (PR middle-end/42233)

Matthias Klose doko@ubuntu.com
Tue Mar 23 22:28:00 GMT 2010


The backport of this patch in r157274 for the 4.4 branch causes regressions in 
the (e)glibc-2.11 branch on ia64-linux-gnu, sparc-linux-gnu and 
arm-linux-gnueabi. Four testcases fail when building glibc with r157597, and 
don't fail with r157597 and r157274 reverted. The four extra failing testcases are:

TEST bug-regex11.out:
^\(a*\)\1\{9\}\(a\{0,9\}\)\([0-9]*;.*[^a]\2\([0-9]\)\): regexec 4 failed
()(b)\1c\2: regexec 20 failed
(b())\2\1: regexec 21 failed
a()(b)\1c\2: regexec 22 failed
a()d(b)\1c\2: regexec 23 failed
a(b())\2\1: regexec 24 failed
(bb())\2\1: regexec 25 failed
^([^,]*),\1,\1$: regexec 26 failed
^([^,]*),\1,\1$: regexec 27 failed
TEST bug-regex20.out:
re_search 18 failed: -1
re_search 21 failed: -1
re_search 74 failed: -1
TEST nodlopen.out:
opening "nodlopenmod.so" succeeded, FAIL
TEST nodlopen2.out:
opening "nodlopenmod2.so" succeeded, FAIL

Currently tested that on ia64 only, builds for arm and sparc are still running.

   Matthias

On 18.02.2010 21:20, Jakub Jelinek wrote:
> Hi!
>
> While the gimple_boolify patch I've just sent fixes the regression
> on the case where __builtin_expect's second argument is 0, when it is 1
> there is another problem - add_reg_br_prob_note is a hack which can only
> handle the most simple jumps, in particular it doesn't handle the case when
> there is more than one jump and on the testcase from this PR we have two
> jumps.
>
> The following patch fixes it by passing down probability from
> expand_gimple_cond (or other callers that know probabilities) down to
> the myriad of dojump.c functions down to do_compare_rtx_and_jump
> and inserts REG_BR_PROB note there.  The passed PROB argument is
> the probability of jump to the if_true_label in functions that
> have 2 label arguments, or -1 if REG_BR_PROB note should not be inserted
> (when probability is unknown).
>
> Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk?
>
> 2010-02-18  Jakub Jelinek<jakub@redhat.com>
>
> 	PR middle-end/42233
> 	* expr.h (jumpifnot, jumpifnot_1, jumpif, jumpif_1, do_jump,
> 	do_jump_1, do_compare_rtx_and_jump): Add PROB argument.
> 	* dojump.c: Include output.h.
> 	(inv): New inline function.
> 	(jumpifnot, jumpifnot_1, jumpif, jumpif_1, do_jump_1, do_jump,
> 	do_jump_by_parts_greater_rtx, do_jump_by_parts_greater,
> 	do_jump_by_parts_zero_rtx, do_jump_by_parts_equality_rtx,
> 	do_jump_by_parts_equality, do_compare_and_jump): Add PROB
> 	argument, pass it down to other calls.
> 	(do_compare_rtx_and_jump): Likewise.  If PROB is not -1,
> 	add REG_BR_PROB note to the conditional jump.
> 	* cfgexpand.c (add_reg_br_prob_note): Removed.
> 	(expand_gimple_cond): Don't call it, add the probability
> 	as last argument to jumpif_1/jumpifnot_1.
> 	* Makefile.in (dojump.o): Depend on output.h.
> 	* builtins.c (expand_errno_check): Adjust do_compare_rtx_and_jump
> 	callers.
> 	* expmed.c (emit_store_flag_force, do_cmp_and_jump): Likewise.
> 	* stmt.c (do_jump_if_equal): Likewise.
> 	* cfgrtl.c (rtl_lv_add_condition_to_bb): Likewise.
> 	* loop-unswitch.c (compare_and_jump_seq): Likewise.
> 	* config/rs6000/rs6000.c (rs6000_aix_emit_builtin_unwind_init):
> 	Likewise.
> 	* optabs.c (expand_doubleword_shift, expand_abs): Likewise.
> 	* expr.c (expand_expr_real_1): Adjust do_jump, jumpifnot and
> 	jumpifnot_1 callers.
> 	(expand_expr_real_2): Adjust jumpifnot_1 and do_compare_rtx_and_jump
> 	callers.
> 	(store_expr): Adjust jumpifnot caller.
> 	(store_constructor): Adjust jumpif caller.



More information about the Gcc-patches mailing list