diff mbox

Use RPO order for domwalk dominator children sort

Message ID alpine.LSU.2.11.1610181600300.2258@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Oct. 18, 2016, 2:03 p.m. UTC
For

extern void baz ();
extern void boo ();
extern void bla ();
int a[100];
void foo (int n)
{
  for (int j = 0; j < n; ++j)
    {
      if (a[j+5])
        {
          if (a[j])
            break;
          baz ();
        }
      else
        bla ();
      boo ();
    }
}

we happen to visit BBs in an unfortunate order so that we do not
have all predecessors visited when visiting the BB of boo().  This
is because domwalk uses a postorder on the inverted graph to
order dominator children -- that doesn't play well with loops
(as we've figured elsewhere before).  The following makes us use
RPO order instead.

This should help EVRP and DOM.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-10-18  Richard Biener  <rguenther@suse.de>

	* domwalk.c (dom_walker::walk): Use RPO order.

Comments

Andreas Schwab Oct. 20, 2016, 10:17 a.m. UTC | #1
On Okt 18 2016, Richard Biener <rguenther@suse.de> wrote:

> 	* domwalk.c (dom_walker::walk): Use RPO order.

FAIL: gcc.dg/graphite/pr35356-1.c scan-tree-dump graphite "if \\(P_8 >= P_9 \\+ 1 && P_9 >= 0\\) \\{"

Andreas.
diff mbox

Patch

Index: gcc/domwalk.c
===================================================================
--- gcc/domwalk.c	(revision 241300)
+++ gcc/domwalk.c	(working copy)
@@ -243,7 +243,7 @@  dom_walker::walk (basic_block bb)
   if (m_dom_direction == CDI_DOMINATORS)
     {
       postorder = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
-      postorder_num = inverted_post_order_compute (postorder);
+      postorder_num = pre_and_rev_post_order_compute (NULL, postorder, true);
       bb_postorder = XNEWVEC (int, last_basic_block_for_fn (cfun));
       for (int i = 0; i < postorder_num; ++i)
 	bb_postorder[postorder[i]] = i;