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 trees. */ > > +/* Reverse postorder index of each basic block. */ > static int *bb_postorder; > > static int > cmp_bb_postorder (const void *a, const void *b) > { > - basic_block bb1 = *(basic_block *)const_cast<void *>(a); > - basic_block bb2 = *(basic_block *)const_cast<void *>(b); > - if (bb1->index == bb2->index) > - return 0; > + basic_block bb1 = *(const basic_block *)(a); > + basic_block bb2 = *(const basic_block *)(b); > + int n1 = bb_postorder[bb1->index], n2 = bb_postorder[bb2->index]; > /* Place higher completion number first (pop off lower number first). */ > - if (bb_postorder[bb1->index] > bb_postorder[bb2->index]) > - return -1; > - return 1; > + return (n1 < n2) - (n1 > n2);
Actually since the 'int *bb_postorder' array is not going to hold negative entries, this can be simply return n2 - n1; (the (A > B) - (A < B) formulation is useful in case signed A - B may overflow) Alexander