Re: [PATCH] Optimize BB sorting in domwalk

2017-07-25 Thread Alexander Monakov
On Tue, 25 Jul 2017, Alexander Monakov wrote: > --- a/gcc/domwalk.c > +++ b/gcc/domwalk.c > @@ -128,19 +128,46 @@ along with GCC; see the file COPYING3. If not see > which is currently an abstraction over walking tree statements. Thus > the dominator walker is currently only useful for

Re: [PATCH] Optimize BB sorting in domwalk

2017-07-25 Thread Richard Biener
On Tue, Jul 25, 2017 at 10:22 AM, Alexander Monakov wrote: > On Mon, 24 Jul 2017, Jeff Law wrote: >> As Uli noted, we should be using std::swap. >> >> Can you please repost ? > > * domwalk.c (cmp_bb_postorder): Simplify. > (sort_bbs_postorder): New function. Use it... > (d

Re: [PATCH] Optimize BB sorting in domwalk

2017-07-25 Thread Alexander Monakov
On Mon, 24 Jul 2017, Jeff Law wrote: > As Uli noted, we should be using std::swap. > > Can you please repost ? * domwalk.c (cmp_bb_postorder): Simplify. (sort_bbs_postorder): New function. Use it... (dom_walker::walk): ...here to optimize common cases. --- gcc/domwalk.c

Re: [PATCH] Optimize BB sorting in domwalk

2017-07-24 Thread Jeff Law
On 07/24/2017 05:29 AM, Alexander Monakov wrote: > Profiling uses of qsort in GCC reveals that a significant portion of calls > comes from domwalk.c where child nodes in dominator tree are reordered > according to postorder numbering. However we know that in dominator trees > the vast majority of

Re: [PATCH] Optimize BB sorting in domwalk

2017-07-24 Thread Ulrich Drepper
Not commenting on the correctness... but On Mon, Jul 24, 2017 at 1:29 PM, Alexander Monakov wrote: > + basic_block bb0 = bbs[0], bb1 = bbs[1]; > + if (bb_postorder[bb0->index] < bb_postorder[bb1->index]) > + bbs[0] = bb1, bbs[1] = bb0; > +} > + else if (__builtin_expect (n ==

[PATCH] Optimize BB sorting in domwalk

2017-07-24 Thread Alexander Monakov
Profiling uses of qsort in GCC reveals that a significant portion of calls comes from domwalk.c where child nodes in dominator tree are reordered according to postorder numbering. However we know that in dominator trees the vast majority of nodes have 0, 2 or 3 children, and handling those cases s