diff mbox

[PR81374] Record the max index of basic block, rather than # of basic blocks

Message ID VI1PR0802MB2176BF61F771A5E61AA7CD0BE7A90@VI1PR0802MB2176.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng July 10, 2017, 2:18 p.m. UTC
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.cheng@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.

Comments

Richard Biener July 17, 2017, 9:21 a.m. UTC | #1
On Mon, Jul 10, 2017 at 4:18 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> 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?

Ok.

Thanks,
Richard.

> Thanks,
> bin
> 2017-07-10  Bin Cheng  <bin.cheng@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 mbox

Patch

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);