Before our rewrite of the scop detection, we used to not have a valid SESE
region under hand, and so we used to do more ad-hoc analysis of data references
by trying to prove that at all levels of a loop nest the data references would
be still valid.

Now that we have a valid SESE region, we can call the scev analysis in the same
way on the same computed loop nest in the scop-detection as in the sese-to-poly.

Next step will be to cache the data references analyzed in the scop detection
and not compute the same info in sese-to-poly.

The patch fixes block-1.f90 that used to ICE on x86_64-linux when compiled with
-m32.  Patch passed bootstrap with BOOT_CFLAGS="-g -O2 -fgraphite-identity
-floop-nest-optimize" and check on x86_64-linux using ISL-0.15.

2015-09-28  Sebastian Pop  <s....@samsung.com>
        Aditya Kumar  <aditya...@samsung.com>

        PR tree-optimization/67754
        * graphite-scop-detection.c (stmt_has_simple_data_refs_p): Call
        scev analysis on the same loop nest as analyze_drs_in_stmts.
        * graphite-sese-to-poly.c (outermost_loop_in_sese_1): Moved and 
renamed...
        (try_generate_gimple_bb): Call outermost_loop_in_sese.
        (analyze_drs_in_stmts): Same.
        * sese.c (outermost_loop_in_sese): ...here.
---
 gcc/graphite-scop-detection.c | 49 ++++++++++++++++++-------------------------
 gcc/graphite-sese-to-poly.c   | 30 ++------------------------
 gcc/sese.c                    | 28 ++++++++++++++++++++++++-
 3 files changed, 49 insertions(+), 58 deletions(-)

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index d95f527..c45df55 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -262,46 +262,37 @@ graphite_can_represent_expr (sese_l scop, loop_p loop, 
tree expr)
 static bool
 stmt_has_simple_data_refs_p (sese_l scop, gimple *stmt)
 {
-  data_reference_p dr;
-  int j;
-  bool res = true;
+  sese region = new_sese (scop.entry, scop.exit);
+  loop_p nest = outermost_loop_in_sese (region, gimple_bb (stmt));
+  loop_p loop = loop_containing_stmt (stmt);
   vec<data_reference_p> drs = vNULL;
-  loop_p outer;
-  loop_p loop_around_scop = get_entry_bb (scop.entry)->loop_father;
 
-  for (outer = loop_containing_stmt (stmt); outer && outer != loop_around_scop;
-       outer = loop_outer (outer))
+  graphite_find_data_references_in_stmt (nest, loop, stmt, &drs);
+
+  int j;
+  data_reference_p dr;
+  FOR_EACH_VEC_ELT (drs, j, dr)
     {
-      graphite_find_data_references_in_stmt (outer,
-                                            loop_containing_stmt (stmt),
-                                            stmt, &drs);
+      int nb_subscripts = DR_NUM_DIMENSIONS (dr);
+      tree ref = DR_REF (dr);
 
-      FOR_EACH_VEC_ELT (drs, j, dr)
+      for (int i = nb_subscripts - 1; i >= 0; i--)
        {
-         int nb_subscripts = DR_NUM_DIMENSIONS (dr);
-         tree ref = DR_REF (dr);
-
-         for (int i = nb_subscripts - 1; i >= 0; i--)
+         if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i))
+             || (TREE_CODE (ref) != ARRAY_REF
+                 && TREE_CODE (ref) != MEM_REF
+                 && TREE_CODE (ref) != COMPONENT_REF))
            {
-             if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i))
-                 || (TREE_CODE (ref) != ARRAY_REF
-                     && TREE_CODE (ref) != MEM_REF
-                     && TREE_CODE (ref) != COMPONENT_REF))
-               {
-                 free_data_refs (drs);
-                 return false;
-               }
-
-             ref = TREE_OPERAND (ref, 0);
+             free_data_refs (drs);
+             return false;
            }
-       }
 
-      free_data_refs (drs);
-      drs.create (0);
+         ref = TREE_OPERAND (ref, 0);
+       }
     }
 
   free_data_refs (drs);
-  return res;
+  return true;
 }
 
 /* Return true only when STMT is simple enough for being handled by Graphite.
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 26f75e9..40b7d31 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -274,32 +274,6 @@ free_scops (vec<scop_p> scops)
   scops.release ();
 }
 
-/* Same as outermost_loop_in_sese, returns the outermost loop
-   containing BB in REGION, but makes sure that the returned loop
-   belongs to the REGION, and so this returns the first loop in the
-   REGION when the loop containing BB does not belong to REGION.  */
-
-static loop_p
-outermost_loop_in_sese_1 (sese region, basic_block bb)
-{
-  loop_p nest = outermost_loop_in_sese (region, bb);
-
-  if (loop_in_sese_p (nest, region))
-    return nest;
-
-  /* When the basic block BB does not belong to a loop in the region,
-     return the first loop in the region.  */
-  nest = nest->inner;
-  while (nest)
-    if (loop_in_sese_p (nest, region))
-      break;
-    else
-      nest = nest->next;
-
-  gcc_assert (nest);
-  return nest;
-}
-
 /* Generates a polyhedral black box only if the bb contains interesting
    information.  */
 
@@ -309,7 +283,7 @@ try_generate_gimple_bb (scop_p scop, basic_block bb)
   vec<data_reference_p> drs;
   drs.create (5);
   sese region = SCOP_REGION (scop);
-  loop_p nest = outermost_loop_in_sese_1 (region, bb);
+  loop_p nest = outermost_loop_in_sese (region, bb);
   gimple_stmt_iterator gsi;
 
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -1934,7 +1908,7 @@ analyze_drs_in_stmts (scop_p scop, basic_block bb, 
vec<gimple *> stmts)
   if (!bb_in_sese_p (bb, region))
     return;
 
-  nest = outermost_loop_in_sese_1 (region, bb);
+  nest = outermost_loop_in_sese (region, bb);
   gbb = gbb_from_bb (bb);
 
   FOR_EACH_VEC_ELT (stmts, i, stmt)
diff --git a/gcc/sese.c b/gcc/sese.c
index ed45410..803f519 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -615,7 +615,7 @@ copy_bb_and_scalar_dependences (basic_block bb, sese region,
 /* Returns the outermost loop in SCOP that contains BB.  */
 
 struct loop *
-outermost_loop_in_sese (sese region, basic_block bb)
+outermost_loop_in_sese_1 (sese region, basic_block bb)
 {
   struct loop *nest;
 
@@ -627,6 +627,32 @@ outermost_loop_in_sese (sese region, basic_block bb)
   return nest;
 }
 
+/* Same as outermost_loop_in_sese_1, returns the outermost loop
+   containing BB in REGION, but makes sure that the returned loop
+   belongs to the REGION, and so this returns the first loop in the
+   REGION when the loop containing BB does not belong to REGION.  */
+
+loop_p
+outermost_loop_in_sese (sese region, basic_block bb)
+{
+  loop_p nest = outermost_loop_in_sese_1 (region, bb);
+
+  if (loop_in_sese_p (nest, region))
+    return nest;
+
+  /* When the basic block BB does not belong to a loop in the region,
+     return the first loop in the region.  */
+  nest = nest->inner;
+  while (nest)
+    if (loop_in_sese_p (nest, region))
+      break;
+    else
+      nest = nest->next;
+
+  gcc_assert (nest);
+  return nest;
+}
+
 /* Sets the false region of an IF_REGION to REGION.  */
 
 void
-- 
2.1.0.243.g30d45f7

Reply via email to