Submitted By: William Harrington (kb0iic at cross-lfs dot org)
Date: 05-31-2014
Initial Package Version: 4.8.3
Origin: Upstream
Upstream Status: Not applied
Description: Do not depend on 2D + 1 form in parallelism check.
http://gcc.gnu.org/ml/gcc-patches/2013-07/msg00524.html

Includes PR tree-optimization/54094

diff -Naur gcc-4.8.3.orig/gcc/ChangeLog gcc-4.8.3/gcc/ChangeLog
--- gcc-4.8.3.orig/gcc/ChangeLog	2014-05-22 09:09:59.000000000 +0000
+++ gcc-4.8.3/gcc/ChangeLog	2014-06-01 05:18:00.010857918 +0000
@@ -729,6 +729,15 @@
 	* config/rs6000/rs6000-protos.h (rs6000_data_alignment): Declare.
 	* config/rs6000/rs6000.c (rs6000_data_alignment): New function.
 
+	2013-07-13  Tobias Grosser  <tobias@grosser.es>
+
+	PR tree-optimization/54094
+	* graphite-clast-to-gimple.c (translate_clast_for_loop): Derive the
+	  scheduling dimension for the parallelism check from the polyhedral
+	  information in the AST.
+	* graphite-dependences.c (carries_deps): Do not assume the schedule is
+	  in 2D + 1 form.
+
 	2013-07-11  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
 	* config/rs6000/rs6000.md (""*tls_gd_low<TLSmode:tls_abi_suffix>"):
diff -Naur gcc-4.8.3.orig/gcc/graphite-clast-to-gimple.c gcc-4.8.3/gcc/graphite-clast-to-gimple.c
--- gcc-4.8.3.orig/gcc/graphite-clast-to-gimple.c	2013-01-10 20:38:27.000000000 +0000
+++ gcc-4.8.3/gcc/graphite-clast-to-gimple.c	2014-06-01 05:16:25.485054767 +0000
@@ -1170,8 +1170,11 @@
   redirect_edge_succ_nodup (next_e, after);
   set_immediate_dominator (CDI_DOMINATORS, next_e->dest, next_e->src);
 
+  isl_set *domain = isl_set_from_cloog_domain (stmt->domain);
+  int scheduling_dim = isl_set_n_dim (domain);
+
   if (flag_loop_parallelize_all
-      && loop_is_parallel_p (loop, bb_pbb_mapping, level))
+      && loop_is_parallel_p (loop, bb_pbb_mapping, scheduling_dim))
     loop->can_be_parallel = true;
 
   return last_e;
diff -Naur gcc-4.8.3.orig/gcc/graphite-dependences.c gcc-4.8.3/gcc/graphite-dependences.c
--- gcc-4.8.3.orig/gcc/graphite-dependences.c	2013-01-10 20:38:27.000000000 +0000
+++ gcc-4.8.3/gcc/graphite-dependences.c	2014-06-01 05:16:25.485054767 +0000
@@ -297,7 +297,7 @@
 	      int depth)
 {
   bool res;
-  int idx, i;
+  int i;
   isl_space *space;
   isl_map *lex, *x;
   isl_constraint *ineq;
@@ -312,13 +312,12 @@
   space = isl_map_get_space (x);
   ineq = isl_inequality_alloc (isl_local_space_from_space (space));
 
-  idx = 2 * depth + 1;
-  for (i = 0; i < idx; i++)
+  for (i = 0; i < depth - 1; i++)
     lex = isl_map_equate (lex, isl_dim_in, i, isl_dim_out, i);
 
   /* in + 1 <= out  */
-  ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_out, idx, 1);
-  ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_in, idx, -1);
+  ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_out, depth - 1, 1);
+  ineq = isl_constraint_set_coefficient_si (ineq, isl_dim_in, depth - 1, -1);
   ineq = isl_constraint_set_constant_si (ineq, -1);
   lex = isl_map_add_constraint (lex, ineq);
   x = isl_map_intersect (x, lex);
diff -Naur gcc-4.8.3.orig/gcc/testsuite/gcc.dg/graphite/pr54094.c gcc-4.8.3/gcc/testsuite/gcc.dg/graphite/pr54094.c
--- gcc-4.8.3.orig/gcc/testsuite/gcc.dg/graphite/pr54094.c	1970-01-01 00:00:00.000000000 +0000
+++ gcc-4.8.3/gcc/testsuite/gcc.dg/graphite/pr54094.c	2014-06-01 05:16:25.485054767 +0000
@@ -0,0 +1,10 @@
+/* { dg-options "-O2 -floop-parallelize-all -floop-nest-optimize" } */
+void dwt_deinterleave_h(int *a, int *b, int dn, int sn, int cas)
+{
+  int i;
+  for (i=0; i<sn; i++)
+    b[i]=a[2*i+cas];
+  for (i=0; i<dn; i++)
+    b[sn+i]=a[(2*i+1-cas)];
+}
+
