Commit 04612f7f by Richard Biener Committed by Richard Biener

graphite-isl-ast-to-gimple.c (gcc_expression_from_isl_ast_expr_id): Simplify…

graphite-isl-ast-to-gimple.c (gcc_expression_from_isl_ast_expr_id): Simplify with removal of the parameter rename map.

2017-10-18  Richard Biener  <rguenther@suse.de>

	* graphite-isl-ast-to-gimple.c (gcc_expression_from_isl_ast_expr_id):
	Simplify with removal of the parameter rename map.
	(set_rename): Likewise.
	(should_copy_to_new_region): Likewise.
	(graphite_copy_stmts_from_block): Likewise.
	(copy_bb_and_scalar_dependences): Remove initialization of
	unused copied_bb_map.
	(copy_def): Remove.
	(copy_internal_parameters): Likewise.
	(graphite_regenerate_ast_isl): Do not call copy_internal_parameters.
	* graphite-scop-detection.c (scop_detection::stmt_simple_for_scop_p):
	Use INTEGRAL_TYPE_P.
	(parameter_index_in_region_1): Rename to ...
	(assign_parameter_index_in_region): ... this.  Assert we have
	a parameter we handle.
	(scan_tree_for_params): Adjust.
	* sese.h (parameter_rename_map_t): Remove.
	(struct sese_info_t): Remove unused parameter_rename_map and
	copied_bb_map members.
	* sese.c (new_sese_info): Adjust.
	(free_sese_info): Likewise.

From-SVN: r253847
parent de57059e
2017-10-18 Richard Biener <rguenther@suse.de>
* graphite-isl-ast-to-gimple.c (gcc_expression_from_isl_ast_expr_id):
Simplify with removal of the parameter rename map.
(set_rename): Likewise.
(should_copy_to_new_region): Likewise.
(graphite_copy_stmts_from_block): Likewise.
(copy_bb_and_scalar_dependences): Remove initialization of
unused copied_bb_map.
(copy_def): Remove.
(copy_internal_parameters): Likewise.
(graphite_regenerate_ast_isl): Do not call copy_internal_parameters.
* graphite-scop-detection.c (scop_detection::stmt_simple_for_scop_p):
Use INTEGRAL_TYPE_P.
(parameter_index_in_region_1): Rename to ...
(assign_parameter_index_in_region): ... this. Assert we have
a parameter we handle.
(scan_tree_for_params): Adjust.
* sese.h (parameter_rename_map_t): Remove.
(struct sese_info_t): Remove unused parameter_rename_map and
copied_bb_map members.
* sese.c (new_sese_info): Adjust.
(free_sese_info): Likewise.
2017-10-18 Martin Liska <mliska@suse.cz>
PR sanitizer/82545
......@@ -264,11 +264,9 @@ gcc_expression_from_isl_ast_expr_id (tree type,
"Could not map isl_id to tree expression");
isl_ast_expr_free (expr_id);
tree t = res->second;
tree *val = region->parameter_rename_map->get(t);
if (!val)
val = &t;
return fold_convert (type, *val);
if (useless_type_conversion_p (type, TREE_TYPE (t)))
return t;
return fold_convert (type, t);
}
/* Converts an isl_ast_expr_int expression E to a widest_int.
......@@ -953,13 +951,6 @@ set_rename (tree old_name, tree expr)
r.safe_push (expr);
region->rename_map->put (old_name, r);
}
tree t;
int i;
/* For a parameter of a scop we don't want to rename it. */
FOR_EACH_VEC_ELT (region->params, i, t)
if (old_name == t)
region->parameter_rename_map->put(old_name, expr);
}
/* Return an iterator to the instructions comes last in the execution order.
......@@ -1138,14 +1129,6 @@ should_copy_to_new_region (gimple *stmt, sese_info_p region)
&& scev_analyzable_p (lhs, region->region))
return false;
/* Do not copy parameters that have been generated in the header of the
scop. */
if (is_gimple_assign (stmt)
&& (lhs = gimple_assign_lhs (stmt))
&& TREE_CODE (lhs) == SSA_NAME
&& region->parameter_rename_map->get(lhs))
return false;
return true;
}
......@@ -1214,7 +1197,7 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
if (codegen_error_p ())
return false;
/* For each SSA_NAME in the parameter_rename_map rename their usage. */
/* For each SCEV analyzable SSA_NAME, rename their usage. */
ssa_op_iter iter;
use_operand_p use_p;
if (!is_gimple_debug (copy))
......@@ -1223,26 +1206,16 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
tree old_name = USE_FROM_PTR (use_p);
if (TREE_CODE (old_name) != SSA_NAME
|| SSA_NAME_IS_DEFAULT_DEF (old_name))
continue;
tree *new_expr = region->parameter_rename_map->get (old_name);
tree new_name;
if (!new_expr
&& scev_analyzable_p (old_name, region->region))
{
gimple_seq stmts = NULL;
new_name = get_rename_from_scev (old_name, &stmts,
bb->loop_father, iv_map);
if (! codegen_error_p ())
gsi_insert_earliest (stmts);
new_expr = &new_name;
}
if (!new_expr)
|| SSA_NAME_IS_DEFAULT_DEF (old_name)
|| ! scev_analyzable_p (old_name, region->region))
continue;
replace_exp (use_p, *new_expr);
gimple_seq stmts = NULL;
tree new_name = get_rename_from_scev (old_name, &stmts,
bb->loop_father, iv_map);
if (! codegen_error_p ())
gsi_insert_earliest (stmts);
replace_exp (use_p, new_name);
}
update_stmt (copy);
......@@ -1288,17 +1261,6 @@ copy_bb_and_scalar_dependences (basic_block bb, edge next_e, vec<tree> iv_map)
gsi_insert_after (&gsi_tgt, ass, GSI_NEW_STMT);
}
vec <basic_block> *copied_bbs = region->copied_bb_map->get (bb);
if (copied_bbs)
copied_bbs->safe_push (new_bb);
else
{
vec<basic_block> bbs;
bbs.create (2);
bbs.safe_push (new_bb);
region->copied_bb_map->put (bb, bbs);
}
if (!graphite_copy_stmts_from_block (bb, new_bb, iv_map))
{
set_codegen_error ();
......@@ -1437,70 +1399,6 @@ scop_to_isl_ast (scop_p scop)
return ast_isl;
}
/* Copy def from sese REGION to the newly created TO_REGION. TR is defined by
DEF_STMT. GSI points to entry basic block of the TO_REGION. */
static void
copy_def (tree tr, gimple *def_stmt, sese_info_p region, sese_info_p to_region,
gimple_stmt_iterator *gsi)
{
if (!defined_in_sese_p (tr, region->region))
return;
ssa_op_iter iter;
use_operand_p use_p;
FOR_EACH_SSA_USE_OPERAND (use_p, def_stmt, iter, SSA_OP_USE)
{
tree use_tr = USE_FROM_PTR (use_p);
/* Do not copy parameters that have been generated in the header of the
scop. */
if (region->parameter_rename_map->get(use_tr))
continue;
gimple *def_of_use = SSA_NAME_DEF_STMT (use_tr);
if (!def_of_use)
continue;
copy_def (use_tr, def_of_use, region, to_region, gsi);
}
gimple *copy = gimple_copy (def_stmt);
gsi_insert_after (gsi, copy, GSI_NEW_STMT);
/* Create new names for all the definitions created by COPY and
add replacement mappings for each new name. */
def_operand_p def_p;
ssa_op_iter op_iter;
FOR_EACH_SSA_DEF_OPERAND (def_p, copy, op_iter, SSA_OP_ALL_DEFS)
{
tree old_name = DEF_FROM_PTR (def_p);
tree new_name = create_new_def_for (old_name, copy, def_p);
region->parameter_rename_map->put(old_name, new_name);
}
update_stmt (copy);
}
static void
copy_internal_parameters (sese_info_p region, sese_info_p to_region)
{
/* For all the parameters which definitino is in the if_region->false_region,
insert code on true_region (if_region->true_region->entry). */
int i;
tree tr;
gimple_stmt_iterator gsi = gsi_start_bb(to_region->region.entry->dest);
FOR_EACH_VEC_ELT (region->params, i, tr)
{
// If def is not in region.
gimple *def_stmt = SSA_NAME_DEF_STMT (tr);
if (def_stmt)
copy_def (tr, def_stmt, region, to_region, &gsi);
}
}
/* Generate out-of-SSA copies for the entry edge FALSE_ENTRY/TRUE_ENTRY
in REGION. */
......@@ -1564,10 +1462,6 @@ graphite_regenerate_ast_isl (scop_p scop)
region->if_region = if_region;
loop_p context_loop = region->region.entry->src->loop_father;
/* Copy all the parameters which are defined in the region. */
copy_internal_parameters(if_region->false_region, if_region->true_region);
edge e = single_succ_edge (if_region->true_region->region.entry->dest);
basic_block bb = split_edge (e);
......
......@@ -1103,7 +1103,7 @@ scop_detection::stmt_simple_for_scop_p (sese_l scop, gimple *stmt,
tree op = gimple_op (stmt, i);
if (!graphite_can_represent_expr (scop, loop, op)
/* We can only constrain on integer type. */
|| (TREE_CODE (TREE_TYPE (op)) != INTEGER_TYPE))
|| ! INTEGRAL_TYPE_P (TREE_TYPE (op)))
{
DEBUG_PRINT (dp << "[scop-detection-fail] "
<< "Graphite cannot represent stmt:\n";
......@@ -1146,49 +1146,23 @@ scop_detection::nb_pbbs_in_loops (scop_p scop)
return res;
}
/* When parameter NAME is in REGION, returns its index in SESE_PARAMS.
Otherwise returns -1. */
/* Assigns the parameter NAME an index in REGION. */
static inline int
parameter_index_in_region_1 (tree name, sese_info_p region)
static void
assign_parameter_index_in_region (tree name, sese_info_p region)
{
gcc_assert (TREE_CODE (name) == SSA_NAME
&& INTEGRAL_TYPE_P (TREE_TYPE (name))
&& ! defined_in_sese_p (name, region->region));
int i;
tree p;
gcc_assert (TREE_CODE (name) == SSA_NAME);
FOR_EACH_VEC_ELT (region->params, i, p)
if (p == name)
return i;
return -1;
}
/* When the parameter NAME is in REGION, returns its index in
SESE_PARAMS. Otherwise this function inserts NAME in SESE_PARAMS
and returns the index of NAME. */
static int
parameter_index_in_region (tree name, sese_info_p region)
{
int i;
gcc_assert (TREE_CODE (name) == SSA_NAME);
/* Cannot constrain on anything else than INTEGER_TYPE parameters. */
if (TREE_CODE (TREE_TYPE (name)) != INTEGER_TYPE)
return -1;
if (!invariant_in_sese_p_rec (name, region->region, NULL))
return -1;
i = parameter_index_in_region_1 (name, region);
if (i != -1)
return i;
return;
i = region->params.length ();
region->params.safe_push (name);
return i;
}
/* In the context of sese S, scan the expression E and translate it to
......@@ -1230,7 +1204,7 @@ scan_tree_for_params (sese_info_p s, tree e)
break;
case SSA_NAME:
parameter_index_in_region (e, s);
assign_parameter_index_in_region (e, s);
break;
case INTEGER_CST:
......
......@@ -157,8 +157,6 @@ new_sese_info (edge entry, edge exit)
region->debug_liveout = NULL;
region->params.create (3);
region->rename_map = new rename_map_t;
region->parameter_rename_map = new parameter_rename_map_t;
region->copied_bb_map = new bb_map_t;
region->bbs.create (3);
region->incomplete_phis.create (3);
......@@ -179,18 +177,8 @@ free_sese_info (sese_info_p region)
it != region->rename_map->end (); ++it)
(*it).second.release ();
for (bb_map_t::iterator it = region->copied_bb_map->begin ();
it != region->copied_bb_map->end (); ++it)
(*it).second.release ();
delete region->rename_map;
delete region->parameter_rename_map;
delete region->copied_bb_map;
region->rename_map = NULL;
region->parameter_rename_map = NULL;
region->copied_bb_map = NULL;
region->bbs.release ();
region->incomplete_phis.release ();
......
......@@ -22,7 +22,6 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_SESE_H
#define GCC_SESE_H
typedef hash_map<tree, tree> parameter_rename_map_t;
typedef hash_map<basic_block, vec<basic_block> > bb_map_t;
typedef hash_map<tree, vec<tree> > rename_map_t;
typedef struct ifsese_s *ifsese;
......@@ -97,15 +96,9 @@ typedef struct sese_info_t
dominator. */
rename_map_t *rename_map;
/* Parameters to be renamed. */
parameter_rename_map_t *parameter_rename_map;
/* Basic blocks contained in this SESE. */
vec<basic_block> bbs;
/* Copied basic blocks indexed by the original bb. */
bb_map_t *copied_bb_map;
/* A vector of phi nodes to be updated when all arguments are available. The
pair contains first the old_phi and second the new_phi. */
vec<phi_rename> incomplete_phis;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment