@@ -2686,32 +2686,16 @@ find_interesting_uses (struct ivopts_data *data)
if (!is_gimple_debug (gsi_stmt (bsi)))
find_interesting_uses_stmt (data, gsi_stmt (bsi));
}
+ free (body);
split_address_groups (data);
if (dump_file && (dump_flags & TDF_DETAILS))
{
- bitmap_iterator bi;
-
- fprintf (dump_file, "\n<Invariant Vars>:\n");
- EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
- {
- struct version_info *info = ver_info (data, i);
- if (info->inv_id)
- {
- fprintf (dump_file, "Inv %d:\t", info->inv_id);
- print_generic_expr (dump_file, info->name, TDF_SLIM);
- fprintf (dump_file, "%s\n",
- info->has_nonlin_use ? "" : "\t(eliminable)");
- }
- }
-
fprintf (dump_file, "\n<IV Groups>:\n");
dump_groups (dump_file, data);
fprintf (dump_file, "\n");
}
-
- free (body);
}
/* Strips constant offsets from EXPR and stores them to OFFSET. If INSIDE_ADDR
@@ -2928,13 +2912,28 @@ struct walk_tree_data
static tree
find_inv_vars_cb (tree *expr_p, int *ws ATTRIBUTE_UNUSED, void *data)
{
- struct walk_tree_data *wdata = (struct walk_tree_data*) data;
+ tree op = *expr_p;
struct version_info *info;
+ struct walk_tree_data *wdata = (struct walk_tree_data*) data;
- if (TREE_CODE (*expr_p) != SSA_NAME)
+ if (TREE_CODE (op) != SSA_NAME)
return NULL_TREE;
- info = name_info (wdata->idata, *expr_p);
+ info = name_info (wdata->idata, op);
+ /* Because we expand simple operations when finding IVs, loop invariant
+ variable that isn't referred by the original loop could be used now.
+ Record such invariant variables here. */
+ if (!info->iv)
+ {
+ struct ivopts_data *idata = wdata->idata;
+ basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (op));
+
+ if (!bb || !flow_bb_inside_loop_p (idata->current_loop, bb))
+ {
+ set_iv (idata, op, op, build_int_cst (TREE_TYPE (op), 0), true);
+ record_invariant (idata, op, false);
+ }
+ }
if (!info->inv_id || info->has_nonlin_use)
return NULL_TREE;
@@ -5395,6 +5394,23 @@ determine_group_iv_costs (struct ivopts_data *data)
if (dump_file && (dump_flags & TDF_DETAILS))
{
+ bitmap_iterator bi;
+
+ /* Dump invariant variables. */
+ fprintf (dump_file, "\n<Invariant Vars>:\n");
+ EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
+ {
+ struct version_info *info = ver_info (data, i);
+ if (info->inv_id)
+ {
+ fprintf (dump_file, "Inv %d:\t", info->inv_id);
+ print_generic_expr (dump_file, info->name, TDF_SLIM);
+ fprintf (dump_file, "%s\n",
+ info->has_nonlin_use ? "" : "\t(eliminable)");
+ }
+ }
+
+ /* Dump invariant expressions. */
fprintf (dump_file, "\n<Invariant Expressions>:\n");
auto_vec <iv_inv_expr_ent *> list (data->inv_expr_tab->elements ());
Hi, At the moment, inv_vars are recognized during finding iv_uses. It's also possible that inv_vars are used when expressing iv_use with specific cand. Unfortunately, such inv_vars are neither recognized nor considered in reg pressure estimation. This patch modifies find_inv_vars_cb so that such invariant variables are also recognized and recorded. The patch also moves dump information later so that all invariant variables can be dumped. Is it OK? Thanks bin 2017-04-11 Bin Cheng <bin.cheng@arm.com> * tree-ssa-loop-ivopts.c (find_interesting_uses): Move inv vars dump to ... (determine_group_iv_costs): ... here. (find_inv_vars_cb): Record inv var if it's not recorded before. From 35a08dbd8d12cb186bf725b5af7837a86c29167d Mon Sep 17 00:00:00 2001 From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com> Date: Tue, 14 Mar 2017 13:48:17 +0000 Subject: [PATCH 26/33] record-newly-used-inv_var-20170224.txt --- gcc/tree-ssa-loop-ivopts.c | 56 +++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 20 deletions(-)