Re: Convert profile probabilities to new type

2017-07-01 Thread Jan Hubicka
> The following patch should restore things:
> 
> diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
> index dd72828..fa88259 100644
> --- a/gcc/sel-sched-ir.c
> +++ b/gcc/sel-sched-ir.c
> @@ -4747,8 +4747,10 @@ compute_succs_info (insn_t insn, short flags)
>sinfo->probs_ok.safe_push (
>   /* FIXME: Improve calculation when skipping
> inner loop to exits.  */
> -si.bb_end && si.e1->probability.initialized_p ()
> - ? si.e1->probability.to_reg_br_prob_base ()
> +si.bb_end
> + ? (si.e1->probability.initialized_p ()
> +   ? si.e1->probability.to_reg_br_prob_base ()
> +   : 0)
>   : REG_BR_PROB_BASE);
>sinfo->succs_ok_n++;
>  }
Hi,
I have tested that it indeed fixes the ICE and weant ahead and comitted it.

Honza


Re: Convert profile probabilities to new type

2017-07-01 Thread Jan Hubicka
Hi,
I have checked in the following fix.

Index: config/pa/pa.c
===
--- config/pa/pa.c  (revision 249854)
+++ config/pa/pa.c  (working copy)
@@ -10723,7 +10723,8 @@ pa_expand_compare_and_swap_loop (rtx mem
 
   /* Mark this jump predicted not taken.  */
   emit_cmp_and_jump_insns (success, const0_rtx, EQ, const0_rtx,
-   GET_MODE (success), 1, label, 0);
+   GET_MODE (success), 1, label,
+  profile_probability::guessed_never ());
   return true;
 }
 


Re: Convert profile probabilities to new type

2017-06-30 Thread Joseph Myers
Also seeing a possibly related failure from my glibc bot, building for 
hppa-linux-gnu:

/scratch/jmyers/glibc-bot/src/gcc/gcc/config/pa/pa.c: In function 'bool 
pa_expand_compare_and_swap_loop(rtx, rtx, rtx, rtx)':
/scratch/jmyers/glibc-bot/src/gcc/gcc/config/pa/pa.c:10726:59: error: could not 
convert '0' from 'int' to 'profile_probability'
GET_MODE (success), 1, label, 0);
   ^

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: Convert profile probabilities to new type

2017-06-30 Thread Jan Hubicka
> 
> After the change, edges that fail the predicate contribute REG_BR_PROB_BASE in
> the upper hunk, but 0 in the lower hunk. Before the change, they contributed 0
> in both cases.
> 
> The following patch should restore things:
> 
> diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
> index dd72828..fa88259 100644
> --- a/gcc/sel-sched-ir.c
> +++ b/gcc/sel-sched-ir.c
> @@ -4747,8 +4747,10 @@ compute_succs_info (insn_t insn, short flags)
>sinfo->probs_ok.safe_push (
>   /* FIXME: Improve calculation when skipping
> inner loop to exits.  */
> -si.bb_end && si.e1->probability.initialized_p ()
> - ? si.e1->probability.to_reg_br_prob_base ()
> +si.bb_end
> + ? (si.e1->probability.initialized_p ()
> +   ? si.e1->probability.to_reg_br_prob_base ()
> +   : 0)
>   : REG_BR_PROB_BASE);
>sinfo->succs_ok_n++;
>  }

Ah, thanks!  This looks OK to me.
I was not quite sure what to do with missing probabilities in this case.

Honza


Re: Convert profile probabilities to new type

2017-06-30 Thread Alexander Monakov
On Fri, 30 Jun 2017, Andreas Schwab wrote:

> This breaks ia64, a lot of testsuite failures like this:
> 
> FAIL: c-c++-common/torture/pr53505.c   -O3 -fomit-frame-pointer 
> -funroll-loops -fpeel-loops -ftracer -finline-functions  (internal compiler 
> error)
> FAIL: c-c++-common/torture/pr53505.c   -O3 -fomit-frame-pointer 
> -funroll-loops -fpeel-loops -ftracer -finline-functions  (test for excess 
> errors)
> Excess errors:
> during RTL pass: mach
> /usr/local/gcc/gcc-20170630/gcc/testsuite/c-c++-common/torture/pr53505.c:26:1:
>  internal compiler error: in merge_expr, at sel-sched-ir.c:1886

The patch introduced a new inconsistency in sel-sched-ir.c:

@@ -4747,7 +4747,9 @@ compute_succs_info (insn_t insn, short flags)
   sinfo->probs_ok.safe_push (
/* FIXME: Improve calculation when skipping
inner loop to exits.  */
-si.bb_end ? si.e1->probability : REG_BR_PROB_BASE);
+si.bb_end && si.e1->probability.initialized_p ()
+   ? si.e1->probability.to_reg_br_prob_base ()
+   : REG_BR_PROB_BASE);
   sinfo->succs_ok_n++;
 }
   else
@@ -4756,8 +4758,8 @@ compute_succs_info (insn_t insn, short flags)
   /* Compute all_prob.  */
   if (!si.bb_end)
 sinfo->all_prob = REG_BR_PROB_BASE;
-  else
-sinfo->all_prob += si.e1->probability;
+  else if (si.e1->probability.initialized_p ())
+sinfo->all_prob += si.e1->probability.to_reg_br_prob_base ();

   sinfo->all_succs_n++;
 }

After the change, edges that fail the predicate contribute REG_BR_PROB_BASE in
the upper hunk, but 0 in the lower hunk. Before the change, they contributed 0
in both cases.

The following patch should restore things:

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index dd72828..fa88259 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -4747,8 +4747,10 @@ compute_succs_info (insn_t insn, short flags)
   sinfo->probs_ok.safe_push (
/* FIXME: Improve calculation when skipping
inner loop to exits.  */
-si.bb_end && si.e1->probability.initialized_p ()
-   ? si.e1->probability.to_reg_br_prob_base ()
+si.bb_end
+   ? (si.e1->probability.initialized_p ()
+   ? si.e1->probability.to_reg_br_prob_base ()
+   : 0)
: REG_BR_PROB_BASE);
   sinfo->succs_ok_n++;
 }


Re: Convert profile probabilities to new type

2017-06-30 Thread Andreas Schwab
This breaks ia64, a lot of testsuite failures like this:

FAIL: c-c++-common/torture/pr53505.c   -O3 -fomit-frame-pointer -funroll-loops 
-fpeel-loops -ftracer -finline-functions  (internal compiler error)
FAIL: c-c++-common/torture/pr53505.c   -O3 -fomit-frame-pointer -funroll-loops 
-fpeel-loops -ftracer -finline-functions  (test for excess errors)
Excess errors:
during RTL pass: mach
/usr/local/gcc/gcc-20170630/gcc/testsuite/c-c++-common/torture/pr53505.c:26:1: 
internal compiler error: in merge_expr, at sel-sched-ir.c:1886
0x410b897f merge_expr(_expr*, _expr*, rtx_insn*)
../../gcc/sel-sched-ir.c:1886
0x410c809f av_set_union_and_live(_list_node**, _list_node**, 
bitmap_head*, bitmap_head*, rtx_insn*)
../../gcc/sel-sched-ir.c:2278
0x410e430f compute_av_set_at_bb_end
../../gcc/sel-sched.c:2808
0x410e430f compute_av_set_inside_bb
../../gcc/sel-sched.c:2980
0x410e52ff move_op_at_first_insn
../../gcc/sel-sched.c:6070
0x410e889f code_motion_path_driver
../../gcc/sel-sched.c:6659
0x410e90af code_motion_process_successors
../../gcc/sel-sched.c:6346
0x410e90af code_motion_path_driver
../../gcc/sel-sched.c:6612
0x410ea57f move_op
../../gcc/sel-sched.c:6704
0x410ea57f move_exprs_to_boundary
../../gcc/sel-sched.c:5227
0x410ea57f schedule_expr_on_boundary
../../gcc/sel-sched.c:5440
0x410f4e2f fill_insns
../../gcc/sel-sched.c:5582
0x410f4e2f schedule_on_fences
../../gcc/sel-sched.c:7356
0x410f4e2f sel_sched_region_2
../../gcc/sel-sched.c:7494
0x410fe48f sel_sched_region_1
../../gcc/sel-sched.c:7536
0x410fe48f sel_sched_region(int)
../../gcc/sel-sched.c:7637
0x410ff60f run_selective_scheduling()
../../gcc/sel-sched.c:7713
0x41a7e6cf ia64_reorg
../../gcc/config/ia64/ia64.c:9764
0x4105564f execute
../../gcc/reorg.c:3946

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: Convert profile probabilities to new type

2017-06-29 Thread Jan Hubicka
Hi,
this patch makes cross compiler for all three targets to build again.
Comitted as obvious.

* arm/arm-builtins.c: Include profile-count.h
* except.c (sjlj_emit_function_enter): Use
profile_probability::unlikely.
Index: config/arm/arm-builtins.c
===
--- config/arm/arm-builtins.c   (revision 249799)
+++ config/arm/arm-builtins.c   (working copy)
@@ -27,6 +27,7 @@
 #include "gimple-expr.h"
 #include "memmodel.h"
 #include "tm_p.h"
+#include "profile-count.h"
 #include "optabs.h"
 #include "emit-rtl.h"
 #include "recog.h"
Index: except.c
===
--- except.c(revision 249800)
+++ except.c(working copy)
@@ -1180,7 +1180,8 @@ sjlj_emit_function_enter (rtx_code_label
 
   emit_cmp_and_jump_insns (x, const0_rtx, NE, 0,
   TYPE_MODE (integer_type_node), 0,
-  dispatch_label, REG_BR_PROB_BASE / 100);
+  dispatch_label,
+  profile_probability::unlikely ());
 #else
   expand_builtin_setjmp_setup (addr, dispatch_label);
 #endif


Re: Convert profile probabilities to new type

2017-06-29 Thread Ramana Radhakrishnan
On Thu, Jun 29, 2017 at 11:24 PM, Jan Hubicka  wrote:
>> On Thu, Jun 29, 2017 at 11:19 PM, Jan Hubicka  wrote:
>> >> After this commit (r249800), GCC builds fail for arm and aarch64:
>> >>
>> >> /gccsrc/gcc/except.c: In function ???void
>> >> sjlj_emit_function_enter(rtx_code_label*)???:
>> >> /gcc-fsf/gccsrc/gcc/except.c:1183: error: conversion from ???int??? to
>> >> non-scalar type ???profile_probability??? requested
>> >> make[2]: *** [except.o] Error 1
>> >
>> > The following patch should help
>> > Index: except.c
>> > ===
>> > --- except.c(revision 249800)
>> > +++ except.c(working copy)
>> > @@ -1180,7 +1180,7 @@ sjlj_emit_function_enter (rtx_code_label
>> >
>> >emit_cmp_and_jump_insns (x, const0_rtx, NE, 0,
>> >TYPE_MODE (integer_type_node), 0,
>> > -  dispatch_label, REG_BR_PROB_BASE / 100);
>> > +  dispatch_label, 
>> > profile_probability::unlikely ());
>> >  #else
>> >expand_builtin_setjmp_setup (addr, dispatch_label);
>> >  #endif
>> >
>> >
>> > I will verify that cross compiler builds and commit it.
>>
>> I also see on arm-none-eabi:
>>
>>
>> In file included from
>> /tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/config/arm/arm-builtins.c:30:0:
>> /tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/optabs.h:251:10:
>> error: 'profile_probability' has not been declared
>>   profile_probability prob
>>   ^
>> /tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/optabs.h:252:8:
>> error: 'profile_probability' has not been declared
>>   = profile_probability::uninitialized ());
>> ^
>
> Yep, this is because we opted to not have #includes in include files which 
> makes it quite painful
> to introduce new data types in their own types which are used elsewhere.
> I will add #include  into arm-builtins.c as well.

It is what it is. I really wish we had a buildbot to do some
pre-commit testing of such major patches .

Ramana

>
> Honza


Re: Convert profile probabilities to new type

2017-06-29 Thread Jan Hubicka
> On Thu, Jun 29, 2017 at 11:19 PM, Jan Hubicka  wrote:
> >> After this commit (r249800), GCC builds fail for arm and aarch64:
> >>
> >> /gccsrc/gcc/except.c: In function ???void
> >> sjlj_emit_function_enter(rtx_code_label*)???:
> >> /gcc-fsf/gccsrc/gcc/except.c:1183: error: conversion from ???int??? to
> >> non-scalar type ???profile_probability??? requested
> >> make[2]: *** [except.o] Error 1
> >
> > The following patch should help
> > Index: except.c
> > ===
> > --- except.c(revision 249800)
> > +++ except.c(working copy)
> > @@ -1180,7 +1180,7 @@ sjlj_emit_function_enter (rtx_code_label
> >
> >emit_cmp_and_jump_insns (x, const0_rtx, NE, 0,
> >TYPE_MODE (integer_type_node), 0,
> > -  dispatch_label, REG_BR_PROB_BASE / 100);
> > +  dispatch_label, 
> > profile_probability::unlikely ());
> >  #else
> >expand_builtin_setjmp_setup (addr, dispatch_label);
> >  #endif
> >
> >
> > I will verify that cross compiler builds and commit it.
> 
> I also see on arm-none-eabi:
> 
> 
> In file included from
> /tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/config/arm/arm-builtins.c:30:0:
> /tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/optabs.h:251:10:
> error: 'profile_probability' has not been declared
>   profile_probability prob
>   ^
> /tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/optabs.h:252:8:
> error: 'profile_probability' has not been declared
>   = profile_probability::uninitialized ());
> ^

Yep, this is because we opted to not have #includes in include files which 
makes it quite painful
to introduce new data types in their own types which are used elsewhere.
I will add #include  into arm-builtins.c as well.

Honza


Re: Convert profile probabilities to new type

2017-06-29 Thread Ramana Radhakrishnan
On Thu, Jun 29, 2017 at 11:19 PM, Jan Hubicka  wrote:
>> After this commit (r249800), GCC builds fail for arm and aarch64:
>>
>> /gccsrc/gcc/except.c: In function ???void
>> sjlj_emit_function_enter(rtx_code_label*)???:
>> /gcc-fsf/gccsrc/gcc/except.c:1183: error: conversion from ???int??? to
>> non-scalar type ???profile_probability??? requested
>> make[2]: *** [except.o] Error 1
>
> The following patch should help
> Index: except.c
> ===
> --- except.c(revision 249800)
> +++ except.c(working copy)
> @@ -1180,7 +1180,7 @@ sjlj_emit_function_enter (rtx_code_label
>
>emit_cmp_and_jump_insns (x, const0_rtx, NE, 0,
>TYPE_MODE (integer_type_node), 0,
> -  dispatch_label, REG_BR_PROB_BASE / 100);
> +  dispatch_label, profile_probability::unlikely 
> ());
>  #else
>expand_builtin_setjmp_setup (addr, dispatch_label);
>  #endif
>
>
> I will verify that cross compiler builds and commit it.

I also see on arm-none-eabi:


In file included from
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/config/arm/arm-builtins.c:30:0:
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/optabs.h:251:10:
error: 'profile_probability' has not been declared
  profile_probability prob
  ^
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/optabs.h:252:8:
error: 'profile_probability' has not been declared
  = profile_probability::uninitialized ());
^
In file included from
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/config/arm/arm-builtins.c:37:0:
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/expr.h:291:63:
error: 'profile_probability' has not been declared
 extern int try_casesi (tree, tree, tree, tree, rtx, rtx, rtx,
profile_probability);
   ^
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/expr.h:292:61:
error: 'profile_probability' has not been declared
 extern int try_tablejump (tree, tree, tree, tree, rtx, rtx,
profile_probability);
 ^
g++ -fno-PIE -c   -O1 -g -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall
-Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -I. -I.
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/.
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/../include
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/../libcpp/include
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/build-arm-none-eabi/host-tools/include
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/build-arm-none-eabi/host-tools/include
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/build-arm-none-eabi/host-tools/include
 
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/../libdecnumber
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/../libdecnumber/dpd
-I../libdecnumber
-I/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/../libbacktrace
  -o hooks.o -MT hooks.o -MMD -MP -MF ./.deps/hooks.TPo
/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/src/gcc/gcc/hooks.c
make[1]: *** [arm-builtins.o] Error 1
make[1]: *** Waiting for unfinished jobs
rm gcov-tool.pod gcov.pod gfdl.pod cpp.pod gpl.pod gcov-dump.pod
fsf-funding.pod gcc.pod
make[1]: Leaving directory
`/tmp/66508161.tmpdir/buildbot/rhe6x86_64--arm-none-eabi/build/build-arm-none-eabi/obj/gcc1/gcc'



Ramana



>
> Honza


Re: Convert profile probabilities to new type

2017-06-29 Thread Jan Hubicka
> After this commit (r249800), GCC builds fail for arm and aarch64:
> 
> /gccsrc/gcc/except.c: In function ???void
> sjlj_emit_function_enter(rtx_code_label*)???:
> /gcc-fsf/gccsrc/gcc/except.c:1183: error: conversion from ???int??? to
> non-scalar type ???profile_probability??? requested
> make[2]: *** [except.o] Error 1

The following patch should help
Index: except.c
===
--- except.c(revision 249800)
+++ except.c(working copy)
@@ -1180,7 +1180,7 @@ sjlj_emit_function_enter (rtx_code_label
 
   emit_cmp_and_jump_insns (x, const0_rtx, NE, 0,
   TYPE_MODE (integer_type_node), 0,
-  dispatch_label, REG_BR_PROB_BASE / 100);
+  dispatch_label, profile_probability::unlikely 
());
 #else
   expand_builtin_setjmp_setup (addr, dispatch_label);
 #endif


I will verify that cross compiler builds and commit it.

Honza