diff mbox

Check depends_on before recording invariant expressions

Message ID DB5PR08MB11446B674D249CDE8D05C64DE7660@DB5PR08MB1144.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng April 29, 2016, 4:04 p.m. UTC
Hi,
This patch fixes a latent bug in IVOPT.  Variable "depends_on" should be checked before recording invariant expression, otherwise we end up with constant (even ZERO) invariant expressions.  Apparently this results in wrong register pressure.

Bootstrap and test on x86_64.  Is it OK?

Thanks,
bin

2016-04-28  Bin Cheng  <bin.cheng@arm.com>

	* tree-ssa-loop-ivopts.c (get_computation_cost_at): Check depends_on
	before using it.

Comments

Richard Biener May 2, 2016, 9:05 a.m. UTC | #1
On Fri, Apr 29, 2016 at 6:04 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This patch fixes a latent bug in IVOPT.  Variable "depends_on" should be checked before recording invariant expression, otherwise we end up with constant (even ZERO) invariant expressions.  Apparently this results in wrong register pressure.
>
> Bootstrap and test on x86_64.  Is it OK?

Ok.

Richard.

> Thanks,
> bin
>
> 2016-04-28  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-ssa-loop-ivopts.c (get_computation_cost_at): Check depends_on
>         before using it.
diff mbox

Patch

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 7be4f16..acafaff 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -4964,12 +4966,12 @@  get_computation_cost_at (struct ivopts_data *data,
       if (depends_on && *depends_on)
 	bitmap_clear (*depends_on);
     }
-  else if (inv_expr_id)
+  else if (inv_expr_id && depends_on && *depends_on)
     {
       *inv_expr_id =
           get_loop_invariant_expr_id (data, ubase, cbase, ratio, address_p);
       /* Clear depends on.  */
-      if (*inv_expr_id != -1 && depends_on && *depends_on)
+      if (*inv_expr_id != -1)
         bitmap_clear (*depends_on);
     }