Hi,
This patch fixes an ICE in new loop distribution code.  When computing 
topological
order for basic blocks it should record the max index of basic block, rather 
than
number of basic blocks.  I didn't add new test because existing tests can catch 
the
ICE as well.

Bootstrap and test on x86_64.  Is it OK?
Thanks,
bin
2017-07-10  Bin Cheng  <bin.ch...@arm.com>

        PR tree-optimization/81374
        * tree-loop-distribution.c (pass_loop_distribution::execute): Record
        the max index of basic blocks, rather than number of basic blocks.
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index be0a660..5c8f29d 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -2614,12 +2614,13 @@ pass_loop_distribution::execute (function *fun)
      lexicographical order.  */
   if (bb_top_order_index == NULL)
     {
+      int rpo_num;
       int *rpo = XNEWVEC (int, last_basic_block_for_fn (cfun));
 
       bb_top_order_index = XNEWVEC (int, last_basic_block_for_fn (cfun));
-      bb_top_order_index_size
-       = pre_and_rev_post_order_compute_fn (cfun, NULL, rpo, true);
-      for (int i = 0; i < bb_top_order_index_size; i++)
+      bb_top_order_index_size = last_basic_block_for_fn (cfun);
+      rpo_num = pre_and_rev_post_order_compute_fn (cfun, NULL, rpo, true);
+      for (int i = 0; i < rpo_num; i++)
        bb_top_order_index[rpo[i]] = i;
 
       free (rpo);

Reply via email to