Commit 14b33c04 by Daniel Berlin Committed by Daniel Berlin

tree-data-ref.c (analyze_array_indexes): Add estimate_only parameter.

2005-09-15  Daniel Berlin  <dberlin@dberlin.org>

	* tree-data-ref.c (analyze_array_indexes): Add estimate_only
	parameter.
	Update callers.
	(estimate_iters_using_array): New function.
	* tree-data-ref.h (estimate_iters_using_array): Prototype
	* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
	Use estimate_iters_using_array instead of analyze_array.

From-SVN: r104312
parent 312ea236
2005-09-15 Daniel Berlin <dberlin@dberlin.org>
* tree-data-ref.c (analyze_array_indexes): Add estimate_only
parameter.
Update callers.
(estimate_iters_using_array): New function.
* tree-data-ref.h (estimate_iters_using_array): Prototype
* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
Use estimate_iters_using_array instead of analyze_array.
2005-09-15 Eric Botcazou <ebotcazou@adacore.com> 2005-09-15 Eric Botcazou <ebotcazou@adacore.com>
* tree-nested.c (get_frame_type): Mark the "non-local frame structure" * tree-nested.c (get_frame_type): Mark the "non-local frame structure"
......
...@@ -799,13 +799,16 @@ estimate_niter_from_size_of_data (struct loop *loop, ...@@ -799,13 +799,16 @@ estimate_niter_from_size_of_data (struct loop *loop,
/* Given an ARRAY_REF node REF, records its access functions. /* Given an ARRAY_REF node REF, records its access functions.
Example: given A[i][3], record in ACCESS_FNS the opnd1 function, Example: given A[i][3], record in ACCESS_FNS the opnd1 function,
i.e. the constant "3", then recursively call the function on opnd0, i.e. the constant "3", then recursively call the function on opnd0,
i.e. the ARRAY_REF "A[i]". The function returns the base name: i.e. the ARRAY_REF "A[i]".
"A". */ If ESTIMATE_ONLY is true, we just set the estimated number of loop
iterations, we don't store the access function.
The function returns the base name: "A". */
static tree static tree
analyze_array_indexes (struct loop *loop, analyze_array_indexes (struct loop *loop,
VEC(tree,heap) **access_fns, VEC(tree,heap) **access_fns,
tree ref, tree stmt) tree ref, tree stmt,
bool estimate_only)
{ {
tree opnd0, opnd1; tree opnd0, opnd1;
tree access_fn; tree access_fn;
...@@ -822,18 +825,29 @@ analyze_array_indexes (struct loop *loop, ...@@ -822,18 +825,29 @@ analyze_array_indexes (struct loop *loop,
if (chrec_contains_undetermined (loop->estimated_nb_iterations)) if (chrec_contains_undetermined (loop->estimated_nb_iterations))
estimate_niter_from_size_of_data (loop, opnd0, access_fn, stmt); estimate_niter_from_size_of_data (loop, opnd0, access_fn, stmt);
VEC_safe_push (tree, heap, *access_fns, access_fn); if (!estimate_only)
VEC_safe_push (tree, heap, *access_fns, access_fn);
/* Recursively record other array access functions. */ /* Recursively record other array access functions. */
if (TREE_CODE (opnd0) == ARRAY_REF) if (TREE_CODE (opnd0) == ARRAY_REF)
return analyze_array_indexes (loop, access_fns, opnd0, stmt); return analyze_array_indexes (loop, access_fns, opnd0, stmt, estimate_only);
/* Return the base name of the data access. */ /* Return the base name of the data access. */
else else
return opnd0; return opnd0;
} }
/* For an array reference REF contained in STMT, attempt to bound the
number of iterations in the loop containing STMT */
void
estimate_iters_using_array (tree stmt, tree ref)
{
analyze_array_indexes (loop_containing_stmt (stmt), NULL, ref, stmt,
true);
}
/* For a data reference REF contained in the statement STMT, initialize /* For a data reference REF contained in the statement STMT, initialize
a DATA_REFERENCE structure, and return it. IS_READ flag has to be a DATA_REFERENCE structure, and return it. IS_READ flag has to be
set to true when REF is in the right hand side of an set to true when REF is in the right hand side of an
...@@ -859,7 +873,7 @@ analyze_array (tree stmt, tree ref, bool is_read) ...@@ -859,7 +873,7 @@ analyze_array (tree stmt, tree ref, bool is_read)
DR_REF (res) = ref; DR_REF (res) = ref;
acc_fns = VEC_alloc (tree, heap, 3); acc_fns = VEC_alloc (tree, heap, 3);
DR_BASE_OBJECT (res) = analyze_array_indexes DR_BASE_OBJECT (res) = analyze_array_indexes
(loop_containing_stmt (stmt), &acc_fns, ref, stmt); (loop_containing_stmt (stmt), &acc_fns, ref, stmt, false);
DR_TYPE (res) = ARRAY_REF_TYPE; DR_TYPE (res) = ARRAY_REF_TYPE;
DR_SET_ACCESS_FNS (res, acc_fns); DR_SET_ACCESS_FNS (res, acc_fns);
DR_IS_READ (res) = is_read; DR_IS_READ (res) = is_read;
......
...@@ -265,6 +265,7 @@ extern void free_dependence_relations (varray_type); ...@@ -265,6 +265,7 @@ extern void free_dependence_relations (varray_type);
extern void free_data_refs (varray_type); extern void free_data_refs (varray_type);
extern void compute_subscript_distance (struct data_dependence_relation *); extern void compute_subscript_distance (struct data_dependence_relation *);
extern struct data_reference *analyze_array (tree, tree, bool); extern struct data_reference *analyze_array (tree, tree, bool);
extern void estimate_iters_using_array (tree, tree);
......
...@@ -1434,10 +1434,10 @@ infer_loop_bounds_from_undefined (struct loop *loop) ...@@ -1434,10 +1434,10 @@ infer_loop_bounds_from_undefined (struct loop *loop)
/* For each array access, analyze its access function /* For each array access, analyze its access function
and record a bound on the loop iteration domain. */ and record a bound on the loop iteration domain. */
if (TREE_CODE (op1) == ARRAY_REF) if (TREE_CODE (op1) == ARRAY_REF)
analyze_array (stmt, op1, true); estimate_iters_using_array (stmt, op1);
if (TREE_CODE (op0) == ARRAY_REF) if (TREE_CODE (op0) == ARRAY_REF)
analyze_array (stmt, op0, false); estimate_iters_using_array (stmt, op0);
/* For each signed type variable in LOOP, analyze its /* For each signed type variable in LOOP, analyze its
scalar evolution and record a bound of the loop scalar evolution and record a bound of the loop
...@@ -1488,7 +1488,7 @@ infer_loop_bounds_from_undefined (struct loop *loop) ...@@ -1488,7 +1488,7 @@ infer_loop_bounds_from_undefined (struct loop *loop)
for (args = TREE_OPERAND (stmt, 1); args; for (args = TREE_OPERAND (stmt, 1); args;
args = TREE_CHAIN (args)) args = TREE_CHAIN (args))
if (TREE_CODE (TREE_VALUE (args)) == ARRAY_REF) if (TREE_CODE (TREE_VALUE (args)) == ARRAY_REF)
analyze_array (stmt, TREE_VALUE (args), true); estimate_iters_using_array (stmt, TREE_VALUE (args));
break; break;
} }
......
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