+2015-12-16  Abderrazek Zaafrani  <a.zaafrani@samsung.com>
+
+       * graphite-isl-ast-to-gimple.c: Include isl/schedule_node.h.
+       (set_separate_option): New.
+       (translate_isl_ast_to_gimple::set_options_for_schedule_tree): New.
+       (translate_isl_ast_to_gimple::scop_to_isl_ast): Use scop->schedule.
+       * graphite-optimize-isl.c (optimize_isl): Set scop->schedule, do not
+       free the computed schedule tree.
+       * graphite-poly.c (new_scop): Initialize scop->schedule.
+       * graphite.h: Include isl/schedule.h.
+       (struct scop): Add field schedule.
+
 2015-12-16  Nathan Sidwell  <nathan@acm.org>
 
        * ipa-visibility.c (can_replace_by_local_alias): Make static,
 
 #include <isl/union_map.h>
 #include <isl/ast_build.h>
 #include <isl/val_gmp.h>
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+#include <isl/schedule_node.h>
+#endif
 
 #include "graphite.h"
 
     }
 }
 
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+
+/* Set the "separate" option for the schedule node.  */
+
+static __isl_give isl_schedule_node *
+set_separate_option (__isl_take isl_schedule_node *node, void *user)
+{
+  if (user)
+    return node;
+
+  if (isl_schedule_node_get_type (node) != isl_schedule_node_band)
+    return node;
+
+  /* Set the "separate" option unless it is set earlier to another option.  */
+  if (isl_schedule_node_band_member_get_ast_loop_type (node, 0)
+      == isl_ast_loop_default)
+    return isl_schedule_node_band_member_set_ast_loop_type
+      (node, 0, isl_ast_loop_separate);
+
+  return node;
+}
+#endif
+
 class translate_isl_ast_to_gimple
 {
  public:
 
   __isl_give isl_union_map *generate_isl_schedule (scop_p scop);
 
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+  /* Set the "separate" option for all schedules.  This helps reducing control
+     overhead.  */
+
+  __isl_give isl_schedule *
+    set_options_for_schedule_tree (__isl_take isl_schedule *schedule);
+#endif
+
   /* Set the separate option for all dimensions.
      This helps to reduce control overhead.  */
 
   return id;
 }
 
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+/* Set the separate option for all schedules.  This helps reducing control
+   overhead.  */
+
+__isl_give isl_schedule *
+translate_isl_ast_to_gimple::set_options_for_schedule_tree
+(__isl_take isl_schedule *schedule)
+{
+  return isl_schedule_map_schedule_node_bottom_up
+    (schedule, set_separate_option, NULL);
+}
+#endif
+
 /* Set the separate option for all dimensions.
    This helps to reduce control overhead.  */
 
 __isl_give isl_ast_node *
 translate_isl_ast_to_gimple::scop_to_isl_ast (scop_p scop, ivs_params &ip)
 {
+  isl_ast_node *ast_isl = NULL;
   /* Generate loop upper bounds that consist of the current loop iterator, an
      operator (< or <=) and an expression not involving the iterator.  If this
      option is not set, then the current loop iterator may appear several times
        isl_ast_build_set_before_each_for (context_isl, ast_build_before_for,
                                           dependence);
     }
-  isl_ast_node *ast_isl = isl_ast_build_ast_from_schedule (context_isl,
-                                                          schedule_isl);
+
+#ifdef HAVE_ISL_OPTIONS_SET_SCHEDULE_SERIALIZE_SCCS
+  if (scop->schedule)
+    {
+      scop->schedule = set_options_for_schedule_tree (scop->schedule);
+      ast_isl = isl_ast_build_node_from_schedule (context_isl, scop->schedule);
+      isl_union_map_free(schedule_isl);
+    }
+  else
+    ast_isl = isl_ast_build_ast_from_schedule (context_isl, schedule_isl);
+#else
+  ast_isl = isl_ast_build_ast_from_schedule (context_isl, schedule_isl);
+  isl_schedule_free (scop->schedule);
+#endif
+
   isl_ast_build_free (context_isl);
   return ast_isl;
 }