tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can't get realistic estimates here.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 30 Mar 2016 14:30:57 +0000 (16:30 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 30 Mar 2016 14:30:57 +0000 (14:30 +0000)
* tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can't get realistic
estimates here.
* tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Use also
max_loop_iterations_int.
(tree_unswitch_outer_loop): Likewise.
* tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise.
* tree-vect-loop.c (vect_analyze_loop_2): Likewise.

From-SVN: r234572

gcc/ChangeLog
gcc/tree-ssa-loop-ivopts.c
gcc/tree-ssa-loop-niter.c
gcc/tree-ssa-loop-unswitch.c
gcc/tree-vect-loop.c

index 35af4ecac720b01b32b22a73e8b784babeb296c2..9e4e0acfe2be97bf98a6066c435f3f01cd91795d 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-30  Jan Hubicka  <hubicka@ucw.cz>
+
+       * tree-ssa-loop-niter.c (idx_infer_loop_bounds): We can't get realistic
+       estimates here.
+       * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Use also
+       max_loop_iterations_int.
+       (tree_unswitch_outer_loop): Likewise.
+       * tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise.
+       * tree-vect-loop.c (vect_analyze_loop_2): Likewise.
+
 2016-03-30  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/70450
index 99dd4d0b7ec25220dc545137dfaf9cf547454f5b..29c4ba4cf56b46c7dc5eb176b0ab99f880bba6bb 100644 (file)
@@ -121,7 +121,11 @@ avg_loop_niter (struct loop *loop)
 {
   HOST_WIDE_INT niter = estimated_stmt_executions_int (loop);
   if (niter == -1)
-    return AVG_LOOP_NITER (loop);
+    {
+      niter = max_stmt_executions_int (loop);
+      if (niter == -1 || niter > AVG_LOOP_NITER (loop))
+        return AVG_LOOP_NITER (loop);
+    }
 
   return niter;
 }
index 81689fc1aa432d710dfaa0ca76fc30ab1f09c609..c93e563e51ce090460d6aa39c1bb92be2d879af6 100644 (file)
@@ -3115,7 +3115,6 @@ idx_infer_loop_bounds (tree base, tree *idx, void *dta)
   tree low, high, type, next;
   bool sign, upper = true, at_end = false;
   struct loop *loop = data->loop;
-  bool reliable = true;
 
   if (TREE_CODE (base) != ARRAY_REF)
     return true;
@@ -3187,14 +3186,14 @@ idx_infer_loop_bounds (tree base, tree *idx, void *dta)
       && tree_int_cst_compare (next, high) <= 0)
     return true;
 
-  /* If access is not executed on every iteration, we must ensure that overlow may
-     not make the access valid later.  */
+  /* If access is not executed on every iteration, we must ensure that overlow
+     may not make the access valid later.  */
   if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (data->stmt))
       && scev_probably_wraps_p (initial_condition_in_loop_num (ev, loop->num),
                                step, data->stmt, loop, true))
-    reliable = false;
+    upper = false;
 
-  record_nonwrapping_iv (loop, init, step, data->stmt, low, high, reliable, upper);
+  record_nonwrapping_iv (loop, init, step, data->stmt, low, high, false, upper);
   return true;
 }
 
index dd6fd01256a27998bfb3f3eb9089e4d8597cd380..77acd66e997351a6fe4898e31960ef07aeedf1a8 100644 (file)
@@ -223,6 +223,8 @@ tree_unswitch_single_loop (struct loop *loop, int num)
       /* If the loop is not expected to iterate, there is no need
         for unswitching.  */
       iterations = estimated_loop_iterations_int (loop);
+      if (iterations < 0)
+        iterations = max_loop_iterations_int (loop);
       if (iterations >= 0 && iterations <= 1)
        {
          if (dump_file && (dump_flags & TDF_DETAILS))
@@ -439,6 +441,8 @@ tree_unswitch_outer_loop (struct loop *loop)
   /* If the loop is not expected to iterate, there is no need
       for unswitching.  */
   iterations = estimated_loop_iterations_int (loop);
+  if (iterations < 0)
+    iterations = max_loop_iterations_int (loop);
   if (iterations >= 0 && iterations <= 1)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
index d813b86259267a88273c77f99c271ee98ac55af3..f977ee9351b1b4339e5a19c3a5508f7de80cc40e 100644 (file)
@@ -2063,6 +2063,8 @@ start_over:
 
   estimated_niter
     = estimated_stmt_executions_int (LOOP_VINFO_LOOP (loop_vinfo));
+  if (estimated_niter != -1)
+    estimated_niter = max_niter;
   if (estimated_niter != -1
       && ((unsigned HOST_WIDE_INT) estimated_niter
           <= MAX (th, (unsigned)min_profitable_estimate)))