+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)
+{
+ gimple_seq stmts;
+ gimple_stmt_iterator si;
+ gimple_stmt_iterator gsi;
+ tree var = force_gimple_operand (expr, &stmts, true, NULL_TREE);
+ gimple stmt = gimple_build_assign (res, var);
+ VEC (gimple, heap) *x = VEC_alloc (gimple, heap, 3);
+
+ if (!stmts)
+ stmts = gimple_seq_alloc ();
+ si = gsi_last (stmts);
+ gsi_insert_after (&si, 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));
+
+ if (gimple_code (after_stmt) == GIMPLE_PHI)
+ {
+ gsi = gsi_after_labels (gimple_bb (after_stmt));
+ gsi_insert_seq_before (&gsi, stmts, GSI_NEW_STMT);
+ }
+ else
+ {
+ gsi = gsi_for_stmt (after_stmt);
+ gsi_insert_seq_after (&gsi, stmts, GSI_NEW_STMT);
+ }
+
+ analyze_drs_in_stmts (scop, gimple_bb (after_stmt), x);
+ VEC_free (gimple, heap, x);
+}
+
+/* Creates a poly_bb_p for basic_block BB from the existing PBB. */
+
+static void
+new_pbb_from_pbb (scop_p scop, poly_bb_p pbb, basic_block bb)
+{
+ VEC (data_reference_p, heap) *drs = VEC_alloc (data_reference_p, heap, 3);
+ gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
+ gimple_bb_p gbb1 = new_gimple_bb (bb, drs);
+ poly_bb_p pbb1 = new_poly_bb (scop, gbb1);
+ int index, n = VEC_length (poly_bb_p, SCOP_BBS (scop));
+
+ /* The INDEX of PBB in SCOP_BBS. */
+ for (index = 0; index < n; index++)
+ if (VEC_index (poly_bb_p, SCOP_BBS (scop), index) == pbb)
+ break;
+
+ if (PBB_DOMAIN (pbb))
+ ppl_new_Pointset_Powerset_C_Polyhedron_from_Pointset_Powerset_C_Polyhedron
+ (&PBB_DOMAIN (pbb1), PBB_DOMAIN (pbb));
+
+ GBB_PBB (gbb1) = pbb1;
+ GBB_CONDITIONS (gbb1) = VEC_copy (gimple, heap, GBB_CONDITIONS (gbb));
+ GBB_CONDITION_CASES (gbb1) = VEC_copy (gimple, heap, GBB_CONDITION_CASES (gbb));
+ VEC_safe_insert (poly_bb_p, heap, SCOP_BBS (scop), index + 1, pbb1);
+}
+
+/* Insert on edge E the assignment "RES := EXPR". */
+
+static void
+insert_out_of_ssa_copy_on_edge (scop_p scop, edge e, tree res, tree expr)