aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pop <sebastian.pop@amd.com>2008-05-30 18:43:50 +0000
committerSebastian Pop <sebastian.pop@amd.com>2008-05-30 18:43:50 +0000
commit729996587c73d4214754d32a42b0f6d6f928e977 (patch)
tree95e11b527ec5cd5791f80a1971eff0832a744fd1
parent209c0ad66de17b9ca383f77853df677ddc3afc93 (diff)
2008-05-30 Sebastian Pop <sebastian.pop@amd.com>
Jan Sjodin <jan.sjodin@amd.com> * graphite.c (create_empty_loop): Renamed graphite_create_new_loop. (graphite_loop_to_gcc_loop): Removed. (remove_all_edges): New. (graphite_stmt_to_gcc_stmt): Renamed translate_clast. (gloog): Remove useless code. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/graphite@136220 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.graphite9
-rw-r--r--gcc/graphite.c281
2 files changed, 117 insertions, 173 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index facd66220c3..b7ba5504a1e 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,3 +1,12 @@
+2008-05-30 Sebastian Pop <sebastian.pop@amd.com>
+ Jan Sjodin <jan.sjodin@amd.com>
+
+ * graphite.c (create_empty_loop): Renamed graphite_create_new_loop.
+ (graphite_loop_to_gcc_loop): Removed.
+ (remove_all_edges): New.
+ (graphite_stmt_to_gcc_stmt): Renamed translate_clast.
+ (gloog): Remove useless code.
+
2008-05-29 Tobias Grosser <grosser@fim.uni-passau.de>
* graphite.c (get_bb_type): Reworked. We distinguish between
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 7cc2f7cbbf6..cd4bbd32cfa 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -1892,34 +1892,6 @@ build_scop_data_accesses (scop_p scop)
}
}
-static struct loop *
-create_empty_loop (edge header_edge)
-{
- int prob;
- edge true_edge, false_edge;
- basic_block loop_header, loop_latch, succ_bb, pred_bb, switch_bb;
-
- switch_bb = create_empty_bb (EXIT_BLOCK_PTR->prev_bb);
-
-
- pred_bb = header_edge->src;
- loop_header = split_edge (header_edge);
- loop_latch = split_edge (single_succ_edge (loop_header));
- succ_bb = single_succ (loop_latch);
-
- make_edge (loop_header, succ_bb, 0);
- set_immediate_dominator (CDI_DOMINATORS, loop_header, switch_bb);
- set_immediate_dominator (CDI_DOMINATORS, loop_latch, loop_header);
-
- false_edge = make_edge (switch_bb, loop_header, 0);
- true_edge = make_edge (switch_bb, succ_bb, EDGE_FALLTHRU);
-
-/* prob = EDGE_FREQUENCY (header_edge);*/
- prob = REG_BR_PROB_BASE / 2;
- return loopify (single_succ_edge (loop_latch), header_edge, switch_bb,
- true_edge, false_edge, 1, prob, REG_BR_PROB_BASE - prob);
-}
-
/* Converts a GMP constant value to a tree and returns it. */
static tree
@@ -2040,23 +2012,53 @@ clast_to_gcc_expression (struct clast_expr *e, tree type,
return NULL_TREE;
}
-/* Translates a Cloog For statement to a GCC loop. */
+/* Creates and inserts an induction variable for the new LOOP,
+ corresponding to Cloog's STMT. */
-static void
-graphite_loop_to_gcc_loop (edge header_edge, scop_p scop,
- struct clast_for *stmt,
- VEC (tree,heap) **remove_ivs ATTRIBUTE_UNUSED)
+static struct loop *
+graphite_create_new_loop (scop_p scop, edge header_edge,
+ struct clast_for *stmt)
{
- bool insert_after;
+ int prob;
+ edge true_edge, false_edge;
+ basic_block loop_header, loop_latch, succ_bb, pred_bb, switch_bb;
+ struct loop *loop;
+ tree ivvar;
block_stmt_iterator bsi;
- tree stmts;
- tree ivvar = create_tmp_var (integer_type_node, "grivtmp");
- struct loop *loop = create_empty_loop (header_edge);
- tree nlb = clast_to_gcc_expression (stmt->LB, integer_type_node,
- SCOP_NEWIVS (scop),
- SCOP_PARAMS (scop));
-
- nlb = force_gimple_operand (nlb, &stmts, true, ivvar);
+ bool insert_after;
+ tree stmts, stride, cond_expr, lowb, upb;
+ edge exit_e;
+
+ switch_bb = create_empty_bb (EXIT_BLOCK_PTR->prev_bb);
+ cond_expr = build3 (COND_EXPR, void_type_node, boolean_false_node,
+ NULL_TREE, NULL_TREE);
+ bsi = bsi_after_labels (switch_bb);
+ bsi_insert_after (&bsi, cond_expr, BSI_NEW_STMT);
+
+
+ pred_bb = header_edge->src;
+ loop_header = split_edge (header_edge);
+ loop_latch = split_edge (single_succ_edge (loop_header));
+ succ_bb = single_succ (loop_latch);
+
+ make_edge (loop_header, succ_bb, 0);
+ set_immediate_dominator (CDI_DOMINATORS, loop_header, switch_bb);
+ set_immediate_dominator (CDI_DOMINATORS, loop_latch, loop_header);
+
+ false_edge = make_edge (switch_bb, loop_header, 0);
+ true_edge = make_edge (switch_bb, succ_bb, EDGE_FALLTHRU);
+
+ prob = REG_BR_PROB_BASE / 2;
+ loop = loopify (single_succ_edge (loop_latch), header_edge, switch_bb,
+ true_edge, false_edge, 1, prob, REG_BR_PROB_BASE - prob);
+
+ /* Create the new induction variable. */
+ stride = gmp_cst_to_tree (stmt->stride);
+ lowb = clast_to_gcc_expression (stmt->LB, integer_type_node,
+ SCOP_NEWIVS (scop), SCOP_PARAMS (scop));
+ ivvar = create_tmp_var (integer_type_node, "graphiteIV");
+
+ lowb = force_gimple_operand (lowb, &stmts, true, ivvar);
if (stmts)
{
bsi_insert_on_edge (loop_preheader_edge (loop), stmts);
@@ -2065,133 +2067,92 @@ graphite_loop_to_gcc_loop (edge header_edge, scop_p scop,
add_referenced_var (ivvar);
standard_iv_increment_position (loop, &bsi, &insert_after);
- create_iv (nlb, gmp_cst_to_tree (stmt->stride), ivvar, loop, &bsi,
- insert_after, &ivvar, NULL);
-
-#if 0
- create_exit_cond (loop, stmt->UB);
-
- /* Build the new upper bound and insert its statements in the
- basic block of the exit condition */
- newupperbound = lle_to_gcc_expression (LL_UPPER_BOUND (newloop),
- LL_LINEAR_OFFSET (newloop),
- type,
- new_ivs,
- invariants, MIN_EXPR, &stmts);
- exit = single_exit (temp);
- exitcond = get_loop_exit_condition (temp);
- bb = bb_for_stmt (exitcond);
- bsi = bsi_after_labels (bb);
- if (stmts)
- bsi_insert_before (&bsi, stmts, BSI_NEW_STMT);
-
-#endif
+ create_iv (lowb, stride, ivvar, loop, &bsi, insert_after, &ivvar, NULL);
- /*
- rename_ivs ();
- remove_old_ivs ();
- */
+ /* Create the loop exit condition. */
+ upb = clast_to_gcc_expression (stmt->UB, integer_type_node,
+ SCOP_NEWIVS (scop), SCOP_PARAMS (scop));
+ exit_e = single_exit (loop);
+ bsi = bsi_last (exit_e->src);
-#if 0
-
- /* Rewrite uses of the old ivs so that they are now specified in terms of
- the new ivs. */
+ upb = force_gimple_operand (upb, &stmts, true, NULL);
+ if (stmts)
+ bsi_insert_after (&bsi, stmts, BSI_NEW_STMT);
- for (i = 0; VEC_iterate (tree, old_ivs, i, oldiv); i++)
- {
- imm_use_iterator imm_iter;
- use_operand_p use_p;
- tree oldiv_def;
- tree oldiv_stmt = SSA_NAME_DEF_STMT (oldiv);
- tree stmt;
+ cond_expr = build2 (LT_EXPR, boolean_type_node, upb, ivvar);
+ cond_expr = build3 (COND_EXPR, void_type_node, cond_expr,
+ NULL_TREE, NULL_TREE);
+ bsi_insert_after (&bsi, cond_expr, BSI_NEW_STMT);
- if (TREE_CODE (oldiv_stmt) == PHI_NODE)
- oldiv_def = PHI_RESULT (oldiv_stmt);
- else
- oldiv_def = SINGLE_SSA_TREE_OPERAND (oldiv_stmt, SSA_OP_DEF);
- gcc_assert (oldiv_def != NULL_TREE);
+ return loop;
+}
- FOR_EACH_IMM_USE_STMT (stmt, imm_iter, oldiv_def)
- {
- tree newiv, stmts;
- lambda_body_vector lbv, newlbv;
-
- gcc_assert (TREE_CODE (stmt) != PHI_NODE);
-
- /* Compute the new expression for the induction
- variable. */
- depth = VEC_length (tree, new_ivs);
- lbv = lambda_body_vector_new (depth, lambda_obstack);
- LBV_COEFFICIENTS (lbv)[i] = 1;
-
- newlbv = lambda_body_vector_compute_new (transform, lbv,
- lambda_obstack);
-
- newiv = lbv_to_gcc_expression (newlbv, TREE_TYPE (oldiv),
- new_ivs, &stmts);
- if (stmts)
- {
- bsi = bsi_for_stmt (stmt);
- bsi_insert_before (&bsi, stmts, BSI_SAME_STMT);
- }
+/* Remove all the edges from BB. */
- FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
- propagate_value (use_p, newiv);
- update_stmt (stmt);
- }
+static void
+remove_all_edges (basic_block bb)
+{
+ edge e;
+ edge_iterator ei;
- /* Remove the now unused induction variable. */
- VEC_safe_push (tree, heap, *remove_ivs, oldiv_stmt);
- }
+ for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
+ remove_edge (e);
- VEC_free (tree, heap, new_ivs);
-#endif
+ for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei)); )
+ remove_edge (e);
}
-static void
-graphite_cond_to_gcc_cond (block_stmt_iterator *bsi ATTRIBUTE_UNUSED, scop_p scop ATTRIBUTE_UNUSED, struct clast_stmt *stmt ATTRIBUTE_UNUSED,
- VEC (tree,heap) **remove_ivs ATTRIBUTE_UNUSED)
-{
-#if 0
- create_cond_bb ();
- create_then_bb ();
-#endif
-}
+/* Translates a CLAST statement STMT to GCC representation. */
-static void
-graphite_stmt_to_gcc_stmt (block_stmt_iterator *bsi, scop_p scop, struct clast_stmt *stmt,
- VEC (tree,heap) **remove_ivs)
+static edge
+translate_clast (scop_p scop, struct clast_stmt *stmt, edge next_e)
{
- if (stmt->type == stmt_root)
- return;
+ if (!stmt)
+ return next_e;
switch (stmt->type)
{
- case stmt_ass:
- gcc_unreachable ();
- break;
+ case stmt_root:
+ return translate_clast (scop, stmt->next, next_e);
case stmt_user:
- graphite_stmt_to_gcc_stmt (bsi, scop, stmt, remove_ivs);
- break;
+ {
+ CloogStatement *cs = ((struct clast_user_stmt *) stmt)->statement;
+ graphite_bb_p gbb = (graphite_bb_p) cs->usr;
+ basic_block bb = gbb->bb;
- case stmt_for:
- graphite_loop_to_gcc_loop (single_succ_edge (bsi->bb), scop,
- (struct clast_for *) stmt, remove_ivs);
- break;
+ remove_all_edges (bb);
+ redirect_edge_succ_nodup (next_e, bb);
+ next_e = make_edge (bb, EXIT_BLOCK_PTR, 0);
- case stmt_guard:
- graphite_cond_to_gcc_cond (bsi, scop, stmt, remove_ivs);
- break;
+#if 0
+ graphite_rename_ivs ();
+#endif
- case stmt_block:
- for ( ; stmt; stmt = stmt->next)
- graphite_stmt_to_gcc_stmt (bsi, scop, stmt, remove_ivs);
+ return translate_clast (scop, stmt->next, next_e);
+ }
- break;
+ case stmt_for:
+ {
+ struct loop *loop = graphite_create_new_loop (scop, next_e,
+ (struct clast_for *) stmt);
+ edge last_e = single_exit (loop);
+
+ next_e = translate_clast (scop, ((struct clast_for *) stmt)->body,
+ single_pred_edge (loop->latch));
+ redirect_edge_succ_nodup (next_e, loop->latch);
+ return translate_clast (scop, stmt->next, last_e);
+ }
+
+ case stmt_block:
+ next_e = translate_clast (scop, ((struct clast_block *) stmt)->body, next_e);
+ return translate_clast (scop, stmt->next, next_e);
+ case stmt_guard:
+ case stmt_ass:
default:
- gcc_unreachable ();
+ /* NIY. */
+ return next_e;
}
}
@@ -2253,36 +2214,10 @@ find_transform (scop_p scop)
static void
gloog (scop_p scop, struct clast_stmt *stmt)
{
- VEC (tree,heap) *remove_ivs = VEC_alloc (tree, heap, 3);
- tree oldiv_stmt;
- struct loop *loop;
- unsigned i;
- block_stmt_iterator bsi;
- basic_block *bbs;
- unsigned nbbs;
-
if (0)
- {
- loop = first_loop_in_scop (scop);
- bbs = get_loop_body_in_dom_order (loop);
- nbbs = loop->num_nodes;
-
- cancel_loop_tree (loop);
- for (i = 0; i < nbbs; i++)
- delete_basic_block (bbs[i]);
-
- bsi = bsi_start (split_edge (single_succ_edge (SCOP_ENTRY (scop))));
-
- for ( ; stmt; stmt = stmt->next)
- graphite_stmt_to_gcc_stmt (&bsi, scop, stmt, &remove_ivs);
-
- for (i = 0; VEC_iterate (tree, remove_ivs, i, oldiv_stmt); i++)
- remove_iv (oldiv_stmt);
-
- }
+ translate_clast (scop, stmt, single_succ_edge (SCOP_ENTRY (scop)));
cloog_clast_free (stmt);
- VEC_free (tree, heap, remove_ivs);
}
/* Returns a matrix representing the data dependence between memory