correctly handle non affine data references
authorSebastian Pop <s.pop@samsung.com>
Thu, 1 Oct 2015 22:04:07 +0000 (22:04 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Thu, 1 Oct 2015 22:04:07 +0000 (22:04 +0000)
2015-10-01  Sebastian Pop  <s.pop@samsung.com>
            Aditya Kumar  <aditya.k7@samsung.com>
        PR tree-optimization/66980
        * graphite-scop-detection.c (stmt_has_simple_data_refs_p): Return false
        when data reference analysis has failed.

Co-Authored-By: Aditya Kumar <aditya.k7@samsung.com>
From-SVN: r228357

gcc/ChangeLog
gcc/graphite-scop-detection.c
gcc/testsuite/gcc.dg/graphite/scop-pr66980.c [new file with mode: 0644]

index 91b417ad6c424bc5383fc3a39e818af69978a490..2bdec1ca4fa064f460eb8fb98124a9b789d17390 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-01  Sebastian Pop  <s.pop@samsung.com>
+           Aditya Kumar  <aditya.k7@samsung.com>
+
+       PR tree-optimization/66980
+       * graphite-scop-detection.c (stmt_has_simple_data_refs_p): Return false
+       when data reference analysis has failed.
+
 2015-10-01  Sebastian Pop  <s.pop@samsung.com>
            Aditya Kumar  <aditya.k7@samsung.com>
 
index c45df5555de08da1f712886a015806c626e164d1..dee4f86d1307593c5c11f2ce06095844c4ae05f4 100644 (file)
@@ -274,6 +274,13 @@ stmt_has_simple_data_refs_p (sese_l scop, gimple *stmt)
   FOR_EACH_VEC_ELT (drs, j, dr)
     {
       int nb_subscripts = DR_NUM_DIMENSIONS (dr);
+
+      if (nb_subscripts < 1)
+       {
+         free_data_refs (drs);
+         return false;
+       }
+
       tree ref = DR_REF (dr);
 
       for (int i = nb_subscripts - 1; i >= 0; i--)
diff --git a/gcc/testsuite/gcc.dg/graphite/scop-pr66980.c b/gcc/testsuite/gcc.dg/graphite/scop-pr66980.c
new file mode 100644 (file)
index 0000000..cf93452
--- /dev/null
@@ -0,0 +1,10 @@
+void foo(unsigned char *in, unsigned char *out, int w, int h)
+{
+  unsigned int i, j;
+  for (i = 0; i < 3*w*h; i++)
+    for (j = 0; j < 3*w*h; j++)
+      out[i * w + j] = in[(i * w + j)*3] + in[(i * w + j)*3 + 1] + in[(i * w + j)*3 + 2];
+}
+
+/* Requires delinearization to be able to represent "i*w".  */
+/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite" { xfail *-*-* } } } */