From: Sebastian Pop <s....@samsung.com>

        * graphite-scop-detection.c (record_loop_in_sese): New.
        (gather_bbs::before_dom_children): Call record_loop_in_sese.
        (build_scops): Remove call to build_sese_loop_nests.
        * sese.c (sese_record_loop): Remove.
        (build_sese_loop_nests): Remove.
        (new_sese_info): Remove region->loops.
        (free_sese_info): Same.
        * sese.h (sese_contains_loop): Same.
        (build_sese_loop_nests): Remove.
        (sese_contains_loop): Remove.
---
 gcc/graphite-scop-detection.c | 29 ++++++++++++++++++++---
 gcc/sese.c                    | 54 -------------------------------------------
 gcc/sese.h                    | 10 --------
 3 files changed, 26 insertions(+), 67 deletions(-)

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index e004185..be33be3 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1874,15 +1874,40 @@ gather_bbs::gather_bbs (cdi_direction direction, scop_p 
scop)
 {
 }
 
+/* Record in execution order the loops fully contained in the region.  */
+
+static void
+record_loop_in_sese (basic_block bb, sese_info_p region)
+{
+  loop_p father = bb->loop_father;
+  if (loop_in_sese_p (father, region->region))
+    {
+      bool found = false;
+      loop_p loop0;
+      int j;
+      FOR_EACH_VEC_ELT (region->loop_nest, j, loop0)
+       if (father == loop0)
+         {
+           found = true;
+           break;
+         }
+      if (!found)
+       region->loop_nest.safe_push (father);
+    }
+}
+
 /* Call-back for dom_walk executed before visiting the dominated
    blocks.  */
 
 edge
 gather_bbs::before_dom_children (basic_block bb)
 {
-  if (!bb_in_sese_p (bb, scop->scop_info->region))
+  sese_info_p region = scop->scop_info;
+  if (!bb_in_sese_p (bb, region->region))
     return NULL;
 
+  record_loop_in_sese (bb, region);
+  
   gcond *stmt = single_pred_cond_non_loop_exit (bb);
 
   if (stmt)
@@ -1991,8 +2016,6 @@ build_scops (vec<scop_p> *scops)
          continue;
        }
 
-      build_sese_loop_nests (scop->scop_info);
-
       find_scop_parameters (scop);
       graphite_dim_t max_dim = PARAM_VALUE (PARAM_GRAPHITE_MAX_NB_SCOP_PARAMS);
 
diff --git a/gcc/sese.c b/gcc/sese.c
index b0f54de..2ecff7d 100644
--- a/gcc/sese.c
+++ b/gcc/sese.c
@@ -43,56 +43,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "sese.h"
 #include "tree-ssa-propagate.h"
 
-/* Record LOOP as occurring in REGION.  */
-
-static void
-sese_record_loop (sese_info_p region, loop_p loop)
-{
-  if (sese_contains_loop (region, loop))
-    return;
-
-  bitmap_set_bit (region->loops, loop->num);
-  region->loop_nest.safe_push (loop);
-}
-
-/* Build the loop nests contained in REGION.  Returns true when the
-   operation was successful.  */
-
-void
-build_sese_loop_nests (sese_info_p region)
-{
-  unsigned i;
-  basic_block bb;
-  struct loop *loop0, *loop1;
-
-  FOR_EACH_BB_FN (bb, cfun)
-    if (bb_in_sese_p (bb, region->region))
-      {
-       struct loop *loop = bb->loop_father;
-
-       /* Only add loops if they are completely contained in the SCoP.  */
-       if (loop->header == bb
-           && bb_in_sese_p (loop->latch, region->region))
-         sese_record_loop (region, loop);
-      }
-
-  /* Make sure that the loops in the SESE_LOOP_NEST are ordered.  It
-     can be the case that an inner loop is inserted before an outer
-     loop.  To avoid this, semi-sort once.  */
-  FOR_EACH_VEC_ELT (region->loop_nest, i, loop0)
-    {
-      if (region->loop_nest.length () == i + 1)
-       break;
-
-      loop1 = region->loop_nest[i + 1];
-      if (loop0->num > loop1->num)
-       {
-         region->loop_nest[i] = loop1;
-         region->loop_nest[i + 1] = loop0;
-       }
-    }
-}
-
 /* For a USE in BB, if BB is outside REGION, mark the USE in the
    LIVEOUTS set.  */
 
@@ -228,7 +178,6 @@ new_sese_info (edge entry, edge exit)
 
   region->region.entry = entry;
   region->region.exit = exit;
-  region->loops = BITMAP_ALLOC (NULL);
   region->loop_nest.create (3);
   region->params.create (3);
   region->rename_map = new rename_map_t;
@@ -244,9 +193,6 @@ new_sese_info (edge entry, edge exit)
 void
 free_sese_info (sese_info_p region)
 {
-  if (region->loops)
-    region->loops = BITMAP_ALLOC (NULL);
-
   region->params.release ();
   region->loop_nest.release ();
 
diff --git a/gcc/sese.h b/gcc/sese.h
index 99df354..f481524 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -86,7 +86,6 @@ typedef struct sese_info_t
   rename_map_t *rename_map;
 
   /* Loops completely contained in this SESE.  */
-  bitmap loops;
   vec<loop_p> loop_nest;
 
   /* Basic blocks contained in this SESE.  */
@@ -107,20 +106,11 @@ typedef struct sese_info_t
 extern sese_info_p new_sese_info (edge, edge);
 extern void free_sese_info (sese_info_p);
 extern void sese_insert_phis_for_liveouts (sese_info_p, basic_block, edge, 
edge);
-extern void build_sese_loop_nests (sese_info_p);
 extern struct loop *outermost_loop_in_sese (sese_l &, basic_block);
 extern tree scalar_evolution_in_region (const sese_l &, loop_p, tree);
 extern bool scev_analyzable_p (tree, sese_l &);
 extern bool invariant_in_sese_p_rec (tree, const sese_l &, bool *);
 
-/* Check that SESE contains LOOP.  */
-
-static inline bool
-sese_contains_loop (sese_info_p sese, struct loop *loop)
-{
-  return bitmap_bit_p (sese->loops, loop->num);
-}
-
 /* The number of parameters in REGION. */
 
 static inline unsigned
-- 
2.5.0

Reply via email to