diff mbox

Revert r234572 (aka PR testsuite/70577)

Message ID 570CC98A.4040505@suse.cz
State New
Headers show

Commit Message

Martin Liška April 12, 2016, 10:10 a.m. UTC
Hello.

As release managers agreed on IRC, following patch reverts r234572
which introduced new PR testsuite/70577.

I've been running bootstrap & regression tests on x86_64-linux-gnu.
Ready to be installed after it finishes?

Thanks,
Martin

Comments

Jan Hubicka April 12, 2016, 12:12 p.m. UTC | #1
> Hello.
> 
> As release managers agreed on IRC, following patch reverts r234572
> which introduced new PR testsuite/70577.
> 
> I've been running bootstrap & regression tests on x86_64-linux-gnu.
> Ready to be installed after it finishes?

OK, thanks for the revert. 
I looked into the prefetch testcase and I think it only needs updating becasue
all arrays are trailing. I will try to debug the galgel issue.

Honza
Richard Biener April 12, 2016, 5:09 p.m. UTC | #2
On April 12, 2016 2:12:14 PM GMT+02:00, Jan Hubicka <hubicka@ucw.cz> wrote:
>> Hello.
>> 
>> As release managers agreed on IRC, following patch reverts r234572
>> which introduced new PR testsuite/70577.
>> 
>> I've been running bootstrap & regression tests on x86_64-linux-gnu.
>> Ready to be installed after it finishes?
>
>OK, thanks for the revert. 
>I looked into the prefetch testcase and I think it only needs updating
>becasue
>all arrays are trailing. I will try to debug the galgel issue.

I think we do not want prefetching for the trailing array of size 5.  This is what the testcase tests.  I think we do want prefetching for a trailing array of size 1000.  Thus I think the previous behavior of estimated niter was better.

Richard.

>Honza
Jan Hubicka April 13, 2016, 10:59 a.m. UTC | #3
> On April 12, 2016 2:12:14 PM GMT+02:00, Jan Hubicka <hubicka@ucw.cz> wrote:
> >> Hello.
> >> 
> >> As release managers agreed on IRC, following patch reverts r234572
> >> which introduced new PR testsuite/70577.
> >> 
> >> I've been running bootstrap & regression tests on x86_64-linux-gnu.
> >> Ready to be installed after it finishes?
> >
> >OK, thanks for the revert. 
> >I looked into the prefetch testcase and I think it only needs updating
> >becasue
> >all arrays are trailing. I will try to debug the galgel issue.
> 
> I think we do not want prefetching for the trailing array of size 5.  This is what the testcase tests.  I think we do want prefetching for a trailing array of size 1000.  Thus I think the previous behavior of estimated niter was better.

Just becasue array has size 1000000 we can't assume that the loop will most
likely 1000000 times.  This is what happens in the go solver that motivated me
for this patch: there are 10 nested loops where each iterates at most 10 times,
but most of time they iterate once or twice (10^10 is simply too much).
Setting estimated niter to 10 makes us to trade setup cost for iteration cost
way too much.

I see that the heuristics worked here bit by accident.  We can assume
trailing arrays to have size 0 or 1 of they aer really such and we can
work out how the slot is allocated and rely on object size, which we
don't at the moment (I think).

In order to enable loop peeling by default next stage1, I extended niter to
also collect likely upper bound. I use it in this path and also in some other
cases. For example I predict

int a[3];
for (i=0;cond;i++)
  if (cond2)
     a[i]=1;

to likely iterest at most 3 times which makes us to peel the loop 3 times but
keep the rolled loop as fallback.  That patch also sets upper bounds for those
trailing arrays of odd sizes.

The likely upper bounds can then often be used in places we use estimates and
upper bounds (such as to trottle down unrolling/vectorizing/ivopts) and to
drive peeling.

Honza
> 
> Richard.
> 
> >Honza
>
diff mbox

Patch

From 978ddfeada20e5597767df120e5d65eef1115c1b Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 12 Apr 2016 12:03:46 +0200
Subject: [PATCH] Revert r234572 (aka PR testsuite/70577)

gcc/ChangeLog:

2016-04-12  Martin Liska  <mliska@suse.cz>

	Revert
	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.
---
 gcc/tree-ssa-loop-ivopts.c   | 6 +-----
 gcc/tree-ssa-loop-niter.c    | 9 +++++----
 gcc/tree-ssa-loop-unswitch.c | 4 ----
 gcc/tree-vect-loop.c         | 2 --
 4 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 7be4f16..a016e9f 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -121,11 +121,7 @@  avg_loop_niter (struct loop *loop)
 {
   HOST_WIDE_INT niter = estimated_stmt_executions_int (loop);
   if (niter == -1)
-    {
-      niter = max_stmt_executions_int (loop);
-      if (niter == -1 || niter > AVG_LOOP_NITER (loop))
-        return AVG_LOOP_NITER (loop);
-    }
+    return AVG_LOOP_NITER (loop);
 
   return niter;
 }
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index c93e563..81689fc 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3115,6 +3115,7 @@  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;
@@ -3186,14 +3187,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))
-    upper = false;
+    reliable = false;
 
-  record_nonwrapping_iv (loop, init, step, data->stmt, low, high, false, upper);
+  record_nonwrapping_iv (loop, init, step, data->stmt, low, high, reliable, upper);
   return true;
 }
 
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 77acd66..dd6fd01 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -223,8 +223,6 @@  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))
@@ -441,8 +439,6 @@  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))
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index f977ee9..d813b86 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2063,8 +2063,6 @@  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)))
-- 
2.8.1