http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50913

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-09 
15:14:30 UTC ---
There is a disconnect on how we analyze data-references during SCOP detection
(outermost_loop is the root of the loop tree) and during SESE-to-poly where
outermost is determined by outermost_loop_in_sese_1 ().  That influences
the SCEV result and thus we do not break the SCOP at a stmt we have to break
it.

The following patch fixes this using a sledgehammer - require the
data-ref to be representable if analyzed with respect to all loops
it can nest in.

Index: graphite-scop-detection.c
===================================================================
--- graphite-scop-detection.c   (revision 183013)
+++ graphite-scop-detection.c   (working copy)
@@ -258,25 +258,33 @@ graphite_can_represent_expr (basic_block
    Graphite.  */

 static bool
-stmt_has_simple_data_refs_p (loop_p outermost_loop, gimple stmt)
+stmt_has_simple_data_refs_p (loop_p outermost_loop ATTRIBUTE_UNUSED,
+                            gimple stmt)
 {
   data_reference_p dr;
   unsigned i;
   int j;
   bool res = true;
-  VEC (data_reference_p, heap) *drs = VEC_alloc (data_reference_p, heap, 5);
+  VEC (data_reference_p, heap) *drs = NULL;
+  loop_p outer;

-  graphite_find_data_references_in_stmt (outermost_loop,
-                                        loop_containing_stmt (stmt),
-                                        stmt, &drs);
+  for (outer = loop_containing_stmt (stmt); outer; outer = loop_outer (outer))
+    {
+      graphite_find_data_references_in_stmt (outer,
+                                            loop_containing_stmt (stmt),
+                                            stmt, &drs);

-  FOR_EACH_VEC_ELT (data_reference_p, drs, j, dr)
-    for (i = 0; i < DR_NUM_DIMENSIONS (dr); i++)
-      if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i)))
-       {
-         res = false;
-         goto done;
-       }
+      FOR_EACH_VEC_ELT (data_reference_p, drs, j, dr)
+         for (i = 0; i < DR_NUM_DIMENSIONS (dr); i++)
+           if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i)))
+             {
+               res = false;
+               goto done;
+             }
+
+      free_data_refs (drs);
+      drs = NULL;
+    }

  done:
   free_data_refs (drs);

Reply via email to