From: Bin Cheng Date: Thu, 11 May 2017 09:54:30 +0000 (+0000) Subject: tree-ssa-loop-ivopts.c (find_interesting_uses): Move inv vars dump to ... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e97cac0271d7322d643fed8c6bf6ba8ec3aad451;p=gcc.git tree-ssa-loop-ivopts.c (find_interesting_uses): Move inv vars dump to ... * 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-SVN: r247896 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4f8a7b3c35c..0b5b6f3d047 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-05-11 Bin Cheng + + * 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. + 2017-05-11 Bin Cheng * tree-ssa-loop-ivopts.c (allow_ip_end_pos_p): Refine comments. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index d8032c85fa0..f95e01e19e3 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2676,32 +2676,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:\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:\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 @@ -2918,13 +2902,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; @@ -5389,6 +5388,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:\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:\n"); auto_vec list (data->inv_expr_tab->elements ());