+ int i;
+ sese region = SCOP_REGION (scop);
+
+ if (!bb_in_sese_p (bb, region))
+ return;
+
+ nest = outermost_loop_in_sese_1 (region, bb);
+ gbb = gbb_from_bb (bb);
+
+ FOR_EACH_VEC_ELT (gimple, stmts, i, stmt)
+ {
+ loop_p loop;
+
+ if (is_gimple_debug (stmt))
+ continue;
+
+ loop = loop_containing_stmt (stmt);
+ if (!loop_in_sese_p (loop, region))
+ loop = nest;
+
+ graphite_find_data_references_in_stmt (nest, loop, stmt,
+ &GBB_DATA_REFS (gbb));
+ }
+}
+
+/* Insert STMT at the end of the STMTS sequence and then insert the
+ statements from STMTS at INSERT_GSI and call analyze_drs_in_stmts
+ on STMTS. */
+
+static void
+insert_stmts (scop_p scop, gimple stmt, gimple_seq stmts,
+ gimple_stmt_iterator insert_gsi)
+{
+ gimple_stmt_iterator gsi;
+ VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3);
+
+ if (!stmts)
+ stmts = gimple_seq_alloc ();
+
+ gsi = gsi_last (stmts);
+ gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+ for (gsi = gsi_start (stmts); !gsi_end_p (gsi); gsi_next (&gsi))
+ VEC_safe_push (gimple, heap, x, gsi_stmt (gsi));
+
+ gsi_insert_seq_before (&insert_gsi, stmts, GSI_SAME_STMT);
+ analyze_drs_in_stmts (scop, gsi_bb (insert_gsi), x);
+ VEC_free (gimple, heap, x);
+}
+
+/* Insert the assignment "RES := EXPR" just after AFTER_STMT. */
+
+static void
+insert_out_of_ssa_copy (scop_p scop, tree res, tree expr, gimple after_stmt)
+{