Commit 6e6568db by Sebastian Pop Committed by Sebastian Pop

Do not compute twice type, lb, and ub.

2011-07-21  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-clast-to-gimple.c (graphite_create_new_loop): Do not
	recompute type, lb, and ub.  Get them from...
	(graphite_create_new_loop_guard): ...here.  Pass in parameter
	pointers to type, lb, and ub.
	(translate_clast_for_loop): Update function calls.
	(translate_clast_for): Same.

From-SVN: r176597
parent dff62090
2011-07-21 Sebastian Pop <sebastian.pop@amd.com> 2011-07-21 Sebastian Pop <sebastian.pop@amd.com>
* graphite-clast-to-gimple.c (graphite_create_new_loop): Do not
recompute type, lb, and ub. Get them from...
(graphite_create_new_loop_guard): ...here. Pass in parameter
pointers to type, lb, and ub.
(translate_clast_for_loop): Update function calls.
(translate_clast_for): Same.
2011-07-21 Sebastian Pop <sebastian.pop@amd.com>
* graphite-clast-to-gimple.c (compute_bounds_for_level): Call * graphite-clast-to-gimple.c (compute_bounds_for_level): Call
psct_dynamic_dim. psct_dynamic_dim.
(translate_clast_for_loop): Pass loop level to dependency_in_loop_p. (translate_clast_for_loop): Pass loop level to dependency_in_loop_p.
......
...@@ -696,23 +696,15 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level, ...@@ -696,23 +696,15 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level,
becomes the child loop of the OUTER_LOOP. NEWIVS_INDEX binds becomes the child loop of the OUTER_LOOP. NEWIVS_INDEX binds
CLooG's scattering name to the induction variable created for the CLooG's scattering name to the induction variable created for the
loop of STMT. The new induction variable is inserted in the NEWIVS loop of STMT. The new induction variable is inserted in the NEWIVS
vector. */ vector and is of type TYPE. */
static struct loop * static struct loop *
graphite_create_new_loop (sese region, edge entry_edge, graphite_create_new_loop (edge entry_edge,
struct clast_for *stmt, struct clast_for *stmt,
loop_p outer, VEC (tree, heap) **newivs, loop_p outer, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t params_index, int level) htab_t newivs_index,
tree type, tree lb, tree ub)
{ {
tree lb_type = gcc_type_for_clast_expr (stmt->LB, region, *newivs,
newivs_index, params_index);
tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, *newivs,
newivs_index, params_index);
tree type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type);
tree lb = clast_to_gcc_expression (type, stmt->LB, region, *newivs,
newivs_index, params_index);
tree ub = clast_to_gcc_expression (type, stmt->UB, region, *newivs,
newivs_index, params_index);
tree stride = gmp_cst_to_tree (type, stmt->stride); tree stride = gmp_cst_to_tree (type, stmt->stride);
tree ivvar = create_tmp_var (type, "graphite_IV"); tree ivvar = create_tmp_var (type, "graphite_IV");
tree iv, iv_after_increment; tree iv, iv_after_increment;
...@@ -887,7 +879,8 @@ static edge ...@@ -887,7 +879,8 @@ static edge
graphite_create_new_loop_guard (sese region, edge entry_edge, graphite_create_new_loop_guard (sese region, edge entry_edge,
struct clast_for *stmt, struct clast_for *stmt,
VEC (tree, heap) *newivs, VEC (tree, heap) *newivs,
htab_t newivs_index, htab_t params_index) htab_t newivs_index, htab_t params_index,
int level, tree *type, tree *lb, tree *ub)
{ {
tree cond_expr; tree cond_expr;
edge exit_edge; edge exit_edge;
...@@ -895,28 +888,30 @@ graphite_create_new_loop_guard (sese region, edge entry_edge, ...@@ -895,28 +888,30 @@ graphite_create_new_loop_guard (sese region, edge entry_edge,
newivs_index, params_index); newivs_index, params_index);
tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, newivs, tree ub_type = gcc_type_for_clast_expr (stmt->UB, region, newivs,
newivs_index, params_index); newivs_index, params_index);
tree type = max_precision_type (lb_type, ub_type);
tree lb = clast_to_gcc_expression (type, stmt->LB, region, newivs, *type = gcc_type_for_iv_of_clast_loop (stmt, level, lb_type, ub_type);
newivs_index, params_index); *lb = clast_to_gcc_expression (*type, stmt->LB, region, newivs,
tree ub = clast_to_gcc_expression (type, stmt->UB, region, newivs, newivs_index, params_index);
newivs_index, params_index); *ub = clast_to_gcc_expression (*type, stmt->UB, region, newivs,
newivs_index, params_index);
/* When ub is simply a constant or a parameter, use lb <= ub. */ /* When ub is simply a constant or a parameter, use lb <= ub. */
if (TREE_CODE (ub) == INTEGER_CST || TREE_CODE (ub) == SSA_NAME) if (TREE_CODE (*ub) == INTEGER_CST || TREE_CODE (*ub) == SSA_NAME)
cond_expr = fold_build2 (LE_EXPR, boolean_type_node, lb, ub); cond_expr = fold_build2 (LE_EXPR, boolean_type_node, *lb, *ub);
else else
{ {
tree one = (POINTER_TYPE_P (type) tree one = (POINTER_TYPE_P (*type)
? size_one_node ? size_one_node
: fold_convert (type, integer_one_node)); : fold_convert (*type, integer_one_node));
/* Adding +1 and using LT_EXPR helps with loop latches that have a /* Adding +1 and using LT_EXPR helps with loop latches that have a
loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes loop iteration count of "PARAMETER - 1". For PARAMETER == 0 this becomes
2^k-1 due to integer overflow, and the condition lb <= ub is true, 2^k-1 due to integer overflow, and the condition lb <= ub is true,
even if we do not want this. However lb < ub + 1 is false, as even if we do not want this. However lb < ub + 1 is false, as
expected. */ expected. */
tree ub_one = fold_build2 (POINTER_TYPE_P (type) ? POINTER_PLUS_EXPR tree ub_one = fold_build2 (POINTER_TYPE_P (*type) ? POINTER_PLUS_EXPR
: PLUS_EXPR, type, ub, one); : PLUS_EXPR, *type, *ub, one);
cond_expr = fold_build2 (LT_EXPR, boolean_type_node, lb, ub_one); cond_expr = fold_build2 (LT_EXPR, boolean_type_node, *lb, ub_one);
} }
exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr); exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr);
...@@ -935,17 +930,19 @@ translate_clast (sese, loop_p, struct clast_stmt *, edge, ...@@ -935,17 +930,19 @@ translate_clast (sese, loop_p, struct clast_stmt *, edge,
- BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping. - BB_PBB_MAPPING is is a basic_block and it's related poly_bb_p mapping.
- PARAMS_INDEX connects the cloog parameters with the gimple parameters in - PARAMS_INDEX connects the cloog parameters with the gimple parameters in
the sese region. */ the sese region. */
static edge static edge
translate_clast_for_loop (sese region, loop_p context_loop, translate_clast_for_loop (sese region, loop_p context_loop,
struct clast_for *stmt, edge next_e, struct clast_for *stmt, edge next_e,
VEC (tree, heap) **newivs, VEC (tree, heap) **newivs,
htab_t newivs_index, htab_t bb_pbb_mapping, htab_t newivs_index, htab_t bb_pbb_mapping,
int level, htab_t params_index) int level, htab_t params_index, tree type,
tree lb, tree ub)
{ {
struct loop *loop = graphite_create_new_loop (region, next_e, stmt, struct loop *loop = graphite_create_new_loop (next_e, stmt,
context_loop, newivs, context_loop, newivs,
newivs_index, params_index, newivs_index,
level); type, lb, ub);
edge last_e = single_exit (loop); edge last_e = single_exit (loop);
edge to_body = single_succ_edge (loop->header); edge to_body = single_succ_edge (loop->header);
basic_block after = to_body->dest; basic_block after = to_body->dest;
...@@ -982,13 +979,15 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt, ...@@ -982,13 +979,15 @@ translate_clast_for (sese region, loop_p context_loop, struct clast_for *stmt,
htab_t newivs_index, htab_t bb_pbb_mapping, int level, htab_t newivs_index, htab_t bb_pbb_mapping, int level,
htab_t params_index) htab_t params_index)
{ {
tree type, lb, ub;
edge last_e = graphite_create_new_loop_guard (region, next_e, stmt, *newivs, edge last_e = graphite_create_new_loop_guard (region, next_e, stmt, *newivs,
newivs_index, params_index); newivs_index, params_index,
level, &type, &lb, &ub);
edge true_e = get_true_edge_from_guard_bb (next_e->dest); edge true_e = get_true_edge_from_guard_bb (next_e->dest);
translate_clast_for_loop (region, context_loop, stmt, true_e, newivs, translate_clast_for_loop (region, context_loop, stmt, true_e, newivs,
newivs_index, bb_pbb_mapping, level, newivs_index, bb_pbb_mapping, level,
params_index); params_index, type, lb, ub);
return last_e; return last_e;
} }
......
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