Patchwork [6/6] Move loop flattening and SLP vectorization at the end of loop transforms.

login
register
mail settings
Submitter Sebastian Pop
Date Oct. 28, 2010, 10:58 p.m.
Message ID <1288306702-5543-7-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/69512/
State New
Headers show

Comments

Sebastian Pop - Oct. 28, 2010, 10:58 p.m.
2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>

	* passes.c (init_optimization_passes): Move pass_flatten_loops and
	pass_slp_vectorize at the end of the loop transforms.
---
 gcc/ChangeLog |    5 +++++
 gcc/passes.c  |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)
Richard Guenther - Oct. 29, 2010, 1:18 p.m.
On Thu, 28 Oct 2010, Sebastian Pop wrote:

> 2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
> 
> 	* passes.c (init_optimization_passes): Move pass_flatten_loops and
> 	pass_slp_vectorize at the end of the loop transforms.
> ---
>  gcc/ChangeLog |    5 +++++
>  gcc/passes.c  |    4 ++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 8907244..d1215cb 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,5 +1,10 @@
>  2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
>  
> +	* passes.c (init_optimization_passes): Move pass_flatten_loops and
> +	pass_slp_vectorize at the end of the loop transforms.
> +
> +2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
> +
>  	* passes.c (init_optimization_passes): Do not call pass_if_conversion
>  	after pass_flatten_loops.
>  	* tree-flow.h (gate_tree_if_conversion): Declared.
> diff --git a/gcc/passes.c b/gcc/passes.c
> index ed81018..82d5c74 100644
> --- a/gcc/passes.c
> +++ b/gcc/passes.c
> @@ -913,11 +913,11 @@ init_optimization_passes (void)
>  	    }
>            NEXT_PASS (pass_predcom);
>  	  NEXT_PASS (pass_complete_unroll);
> -	  NEXT_PASS (pass_flatten_loops);
> -	  NEXT_PASS (pass_slp_vectorize);
>  	  NEXT_PASS (pass_parallelize_loops);
>  	  NEXT_PASS (pass_loop_prefetch);
>  	  NEXT_PASS (pass_iv_optimize);
> +	  NEXT_PASS (pass_flatten_loops);
> +	  NEXT_PASS (pass_slp_vectorize);
>  	  NEXT_PASS (pass_tree_loop_done);

IVOPTs should certainly be after SLP.  I also don't expect loop
flattening to introduce SLP opportunities (I'd be curious for
a testcase where it does so).  Which means simply moving flattening
after IVOPTs should be all.

Richard.
Sebastian Pop - Oct. 29, 2010, 8:52 p.m.
On Fri, Oct 29, 2010 at 08:18, Richard Guenther <rguenther@suse.de> wrote:
> IVOPTs should certainly be after SLP.

Ok.

> I also don't expect loop
> flattening to introduce SLP opportunities (I'd be curious for
> a testcase where it does so).

Whenever the loop nests are not perfectly nested, there is an
opportunity to SLP after loop flattening and if-conversion.
See the last two slides of the presentation that Reza gave at the
summit:

http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=pop-slides.pdf

for (i = 0; i < 1000; i++) {
   if (i & 1) a[i] = b[i] + 1;
   for (j = 0; j < 50; j++) {
     if (j & 1) c[i,j] = d[j] + 1;
   }
}

Sebastian
Richard Guenther - Oct. 29, 2010, 11:40 p.m.
On Fri, Oct 29, 2010 at 10:52 PM, Sebastian Pop <sebpop@gmail.com> wrote:
> On Fri, Oct 29, 2010 at 08:18, Richard Guenther <rguenther@suse.de> wrote:
>> IVOPTs should certainly be after SLP.
>
> Ok.
>
>> I also don't expect loop
>> flattening to introduce SLP opportunities (I'd be curious for
>> a testcase where it does so).
>
> Whenever the loop nests are not perfectly nested, there is an
> opportunity to SLP after loop flattening and if-conversion.
> See the last two slides of the presentation that Reza gave at the
> summit:
>
> http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=pop-slides.pdf
>
> for (i = 0; i < 1000; i++) {
>   if (i & 1) a[i] = b[i] + 1;
>   for (j = 0; j < 50; j++) {
>     if (j & 1) c[i,j] = d[j] + 1;
>   }
> }

That's not SLP I think (the slides are somewhat odd - well, the pseudocode is,
I can't see that the loops are equivalent).

Note that SLP is straight-line code vectorization.

Richard.

> Sebastian
>

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8907244..d1215cb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@ 
 2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* passes.c (init_optimization_passes): Move pass_flatten_loops and
+	pass_slp_vectorize at the end of the loop transforms.
+
+2010-10-20  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* passes.c (init_optimization_passes): Do not call pass_if_conversion
 	after pass_flatten_loops.
 	* tree-flow.h (gate_tree_if_conversion): Declared.
diff --git a/gcc/passes.c b/gcc/passes.c
index ed81018..82d5c74 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -913,11 +913,11 @@  init_optimization_passes (void)
 	    }
           NEXT_PASS (pass_predcom);
 	  NEXT_PASS (pass_complete_unroll);
-	  NEXT_PASS (pass_flatten_loops);
-	  NEXT_PASS (pass_slp_vectorize);
 	  NEXT_PASS (pass_parallelize_loops);
 	  NEXT_PASS (pass_loop_prefetch);
 	  NEXT_PASS (pass_iv_optimize);
+	  NEXT_PASS (pass_flatten_loops);
+	  NEXT_PASS (pass_slp_vectorize);
 	  NEXT_PASS (pass_tree_loop_done);
 	}
       NEXT_PASS (pass_cse_reciprocals);