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.ch...@arm.com>

        * tree-ssa-loop-ivopts.c (get_computation_cost_at): Check depends_on
        before using it.
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);
     }
 

Reply via email to