From: Sebastian Pop <sebpop@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: gcc-graphite@googlegroups.com, Sebastian Pop <sebpop@gmail.com>
Subject: [PATCH 2/3] Do not rewrite out of SSA scalar dependences crossing the limits of the scop.
Date: Tue, 23 Nov 2010 01:32:00 -0000 [thread overview]
Message-ID: <1290467900-14995-2-git-send-email-sebpop@gmail.com> (raw)
In-Reply-To: <1290467900-14995-1-git-send-email-sebpop@gmail.com>
Committed to the graphite branch.
2010-11-22 Sebastian Pop <sebastian.pop@amd.com>
* graphite-sese-to-poly.c (handle_scalar_deps_crossing_scop_limits):
New.
(rewrite_cross_bb_scalar_deps): Pass in the scop. Call
handle_scalar_deps_crossing_scop_limits.
(rewrite_cross_bb_scalar_deps_out_of_ssa): Create an empty BB
after the scop. Update call to rewrite_cross_bb_scalar_deps.
---
gcc/ChangeLog.graphite | 9 +++++++
gcc/graphite-sese-to-poly.c | 54 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index e5df72e..5ccbc63 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,14 @@
2010-11-22 Sebastian Pop <sebastian.pop@amd.com>
+ * graphite-sese-to-poly.c (handle_scalar_deps_crossing_scop_limits):
+ New.
+ (rewrite_cross_bb_scalar_deps): Pass in the scop. Call
+ handle_scalar_deps_crossing_scop_limits.
+ (rewrite_cross_bb_scalar_deps_out_of_ssa): Create an empty BB
+ after the scop. Update call to rewrite_cross_bb_scalar_deps.
+
+2010-11-22 Sebastian Pop <sebastian.pop@amd.com>
+
* sese.c (rename_uses): Call recompute_tree_invariant_for_addr_expr
when replacing a constant in an ADDR_EXPR.
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 77930d5..eec46dc 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2426,13 +2426,57 @@ rewrite_cross_bb_scalar_dependence (tree zero_dim_array, tree def, gimple use_st
update_stmt (use_stmt);
}
+/* For every definition DEF in the SCOP that is used outside the scop,
+ insert a closing-scop definition in the basic block just after this
+ SCOP. */
+
+static void
+handle_scalar_deps_crossing_scop_limits (scop_p scop, tree def, gimple stmt)
+{
+ tree var = create_tmp_reg (TREE_TYPE (def), NULL);
+ tree new_name = make_ssa_name (var, stmt);
+ bool needs_copy = false;
+ use_operand_p use_p;
+ imm_use_iterator imm_iter;
+ gimple use_stmt;
+ sese region = SCOP_REGION (scop);
+
+ FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
+ {
+ if (!bb_in_sese_p (gimple_bb (use_stmt), region))
+ {
+ FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+ {
+ SET_USE (use_p, new_name);
+ }
+ update_stmt (use_stmt);
+ needs_copy = true;
+ }
+ }
+
+ /* Insert in the empty BB just after the scop a use of DEF such
+ that the rewrite of cross_bb_scalar_dependences won't insert
+ arrays everywhere else. */
+ if (needs_copy)
+ {
+ gimple assign = gimple_build_assign (new_name, def);
+ gimple_stmt_iterator psi = gsi_after_labels (SESE_EXIT (region)->dest);
+
+ add_referenced_var (var);
+ SSA_NAME_DEF_STMT (new_name) = assign;
+ update_stmt (assign);
+ gsi_insert_before (&psi, assign, GSI_SAME_STMT);
+ }
+}
+
/* Rewrite the scalar dependences crossing the boundary of the BB
containing STMT with an array. Return true when something has been
changed. */
static bool
-rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
+rewrite_cross_bb_scalar_deps (scop_p scop, gimple_stmt_iterator *gsi)
{
+ sese region = SCOP_REGION (scop);
gimple stmt = gsi_stmt (*gsi);
imm_use_iterator imm_iter;
tree def;
@@ -2473,6 +2517,8 @@ rewrite_cross_bb_scalar_deps (sese region, gimple_stmt_iterator *gsi)
def_bb = gimple_bb (stmt);
+ handle_scalar_deps_crossing_scop_limits (scop, def, stmt);
+
FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
if (gimple_code (use_stmt) == GIMPLE_PHI
&& (res = true))
@@ -2512,14 +2558,18 @@ void
rewrite_cross_bb_scalar_deps_out_of_ssa (scop_p scop)
{
basic_block bb;
+ basic_block exit;
gimple_stmt_iterator psi;
sese region = SCOP_REGION (scop);
bool changed = false;
+ /* Create an extra empty BB after the scop. */
+ exit = split_edge (SESE_EXIT (region));
+
FOR_EACH_BB (bb)
if (bb_in_sese_p (bb, region))
for (psi = gsi_start_bb (bb); !gsi_end_p (psi); gsi_next (&psi))
- changed |= rewrite_cross_bb_scalar_deps (region, &psi);
+ changed |= rewrite_cross_bb_scalar_deps (scop, &psi);
if (changed)
{
--
1.7.0.4
next prev parent reply other threads:[~2010-11-22 23:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 0:25 [PATCH 1/3] Call recompute_tree_invariant_for_addr_expr when replacing a constant in an ADDR_EXPR Sebastian Pop
2010-11-23 1:32 ` Sebastian Pop [this message]
2010-11-23 1:56 ` [PATCH 3/3] Postpone the rewrite out of SSA to the end of the translation to polyhedral representation Sebastian Pop
2010-11-26 10:34 ` Sebastian Pop
2010-11-23 14:23 ` [PATCH 1/3] Call recompute_tree_invariant_for_addr_expr when replacing a constant in an ADDR_EXPR Richard Guenther
2010-11-24 1:10 ` Sebastian Pop
2010-11-24 13:25 ` Richard Guenther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290467900-14995-2-git-send-email-sebpop@gmail.com \
--to=sebpop@gmail.com \
--cc=gcc-graphite@googlegroups.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).