From: Bin Cheng <Bin.Cheng@arm.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: nd <nd@arm.com>, Richard Biener <richard.guenther@gmail.com>
Subject: [PATCH branch/gimple-interchange]obvious cleanup
Date: Tue, 05 Dec 2017 10:07:00 -0000 [thread overview]
Message-ID: <DB5PR0801MB2742BB78C52B18F0CD9FEDC9E73D0@DB5PR0801MB2742.eurprd08.prod.outlook.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
Hi,
This is an obvious cleanup patch doing variable renaming, function inlining.
Is it OK?
Thanks,
bin
2017-12-05 Bin Cheng <bin.cheng@arm.com>
* gimple-loop-interchange.cc (struct induction): Rename fields.
(dump_induction, loop_cand::analyze_induction_var): Update uses.
(loop_cand::undo_simple_reduction): Ditto.
(tree_loop_interchange::map_inductions_to_loop): Ditto.
(tree_loop_interchange::can_interchange_loops): Delete.
(tree_loop_interchange::interchange): Inline can_interchange_loops.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-cleanup-1.patch --]
[-- Type: text/x-patch; name="0001-cleanup-1.patch", Size: 5288 bytes --]
From 734217d0879c246a139d4c55ecd65837b2fa6077 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Tue, 5 Dec 2017 10:00:06 +0000
Subject: [PATCH] cleanup-1
---
gcc/gimple-loop-interchange.cc | 49 +++++++++++++++++-------------------------
1 file changed, 20 insertions(+), 29 deletions(-)
diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index 1f46509..8c396ab 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -100,10 +100,11 @@ typedef struct induction
{
/* IV itself. */
tree var;
- /* Initializer. */
- tree init;
- /* IV's base and step part of SCEV. */
- tree base;
+ /* IV's initializing value, which is the init arg of the IV PHI node. */
+ tree init_val;
+ /* IV's initializing expr, which is (the expanded result of) init_val. */
+ tree init_expr;
+ /* IV's step. */
tree step;
}* induction_p;
@@ -161,7 +162,7 @@ dump_induction (struct loop *loop, induction_p iv)
fprintf (dump_file, " Induction: ");
print_generic_expr (dump_file, iv->var, TDF_SLIM);
fprintf (dump_file, " = {");
- print_generic_expr (dump_file, iv->base, TDF_SLIM);
+ print_generic_expr (dump_file, iv->init_expr, TDF_SLIM);
fprintf (dump_file, ", ");
print_generic_expr (dump_file, iv->step, TDF_SLIM);
fprintf (dump_file, "}_%d\n", loop->num);
@@ -742,8 +743,8 @@ loop_cand::analyze_induction_var (tree var, tree chrec)
{
struct induction *iv = XCNEW (struct induction);
iv->var = var;
- iv->init = init;
- iv->base = chrec;
+ iv->init_val = init;
+ iv->init_expr = chrec;
iv->step = build_int_cst (TREE_TYPE (chrec), 0);
m_inductions.safe_push (iv);
return true;
@@ -757,8 +758,8 @@ loop_cand::analyze_induction_var (tree var, tree chrec)
struct induction *iv = XCNEW (struct induction);
iv->var = var;
- iv->init = init;
- iv->base = CHREC_LEFT (chrec);
+ iv->init_val = init;
+ iv->init_expr = CHREC_LEFT (chrec);
iv->step = CHREC_RIGHT (chrec);
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -938,14 +939,14 @@ loop_cand::undo_simple_reduction (reduction_p re, bitmap dce_seeds)
/* Find all stmts on which expression "MEM_REF[idx]" depends. */
find_deps_in_bb_for_stmt (&stmts, gimple_bb (re->consumer), re->consumer);
/* Because we generate new stmt loading from the MEM_REF to TMP. */
- tree tmp = copy_ssa_name (re->var);
+ tree cond, tmp = copy_ssa_name (re->var);
stmt = gimple_build_assign (tmp, re->init_ref);
gimple_seq_add_stmt (&stmts, stmt);
/* Init new_var to MEM_REF or CONST depending on if it is the first
iteration. */
induction_p iv = m_inductions[0];
- tree cond = fold_build2 (NE_EXPR, boolean_type_node, iv->var, iv->init);
+ cond = fold_build2 (NE_EXPR, boolean_type_node, iv->var, iv->init_val);
new_var = copy_ssa_name (re->var);
stmt = gimple_build_assign (new_var, COND_EXPR, cond, tmp, re->init);
gimple_seq_add_stmt (&stmts, stmt);
@@ -1007,7 +1008,6 @@ public:
private:
void update_data_info (unsigned, unsigned, vec<data_reference_p>, vec<ddr_p>);
bool valid_data_dependences (unsigned, unsigned, vec<ddr_p>);
- bool can_interchange_loops (loop_cand &, loop_cand &);
void interchange_loops (loop_cand &, loop_cand &);
void map_inductions_to_loop (loop_cand &, loop_cand &);
void move_code_to_inner_loop (struct loop *, struct loop *, basic_block *);
@@ -1099,21 +1099,6 @@ tree_loop_interchange::valid_data_dependences (unsigned i_idx, unsigned o_idx,
return true;
}
-/* Return true if ILOOP and OLOOP can be interchanged in terms of code
- transformation. */
-
-bool
-tree_loop_interchange::can_interchange_loops (loop_cand &iloop,
- loop_cand &oloop)
-{
- return (iloop.analyze_carried_vars (NULL)
- && iloop.analyze_lcssa_phis ()
- && oloop.analyze_carried_vars (&iloop)
- && oloop.analyze_lcssa_phis ()
- && iloop.can_interchange_p (NULL)
- && oloop.can_interchange_p (&iloop));
-}
-
/* Interchange two loops specified by ILOOP and OLOOP. */
void
@@ -1227,7 +1212,8 @@ tree_loop_interchange::map_inductions_to_loop (loop_cand &src, loop_cand &tgt)
{
/* Map the IV by creating the same one in target loop. */
tree var_before, var_after;
- tree base = unshare_expr (iv->base), step = unshare_expr (iv->step);
+ tree base = unshare_expr (iv->init_expr);
+ tree step = unshare_expr (iv->step);
create_iv (base, step, SSA_NAME_VAR (iv->var),
tgt.m_loop, &incr_pos, false, &var_before, &var_after);
bitmap_set_bit (m_dce_seeds, SSA_NAME_VERSION (var_before));
@@ -1622,7 +1608,12 @@ tree_loop_interchange::interchange (vec<data_reference_p> datarefs,
loop_cand oloop (m_loop_nest[o_idx], m_loop_nest[o_idx]);
/* Check if we can do transformation for loop interchange. */
- if (!can_interchange_loops (iloop, oloop))
+ if (!iloop.analyze_carried_vars (NULL)
+ || !iloop.analyze_lcssa_phis ()
+ || !oloop.analyze_carried_vars (&iloop)
+ || !oloop.analyze_lcssa_phis ()
+ || !iloop.can_interchange_p (NULL)
+ || !oloop.can_interchange_p (&iloop))
break;
/* Check profitability for loop interchange. */
--
1.9.1
next reply other threads:[~2017-12-05 10:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-05 10:07 Bin Cheng [this message]
2017-12-05 11:24 ` Richard Biener
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=DB5PR0801MB2742BB78C52B18F0CD9FEDC9E73D0@DB5PR0801MB2742.eurprd08.prod.outlook.com \
--to=bin.cheng@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.com \
--cc=richard.guenther@gmail.com \
/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).