Commit 946e1bc7 by Zdenek Dvorak Committed by Zdenek Dvorak

Makefile.in (tree-data-ref.o): Add langhooks.h dependency.

	* Makefile.in (tree-data-ref.o): Add langhooks.h dependency.
	* tree-ssa-loop-niter.c (derive_constant_upper_bound):  Follow
	ud-chains.  Handle AND_EXPR.
	(record_estimate): Record whether the estimate is realistic
	and whether it is derived from a loop exit.
	(record_nonwrapping_iv, idx_infer_loop_bounds, infer_loop_bounds_from_ref,
	infer_loop_bounds_from_array, infer_loop_bounds_from_signedness): New
	functions.
	(compute_estimated_nb_iterations): Take only realistic bounds into
	account.  Set estimate_state.  Use double_ints.
	(infer_loop_bounds_from_undefined): Call infer_loop_bounds_from_array
	and infer_loop_bounds_from_signedness.  Do not consider basic blocks
	that do not have to be always executed.
	(estimate_numbers_of_iterations_loop): Set estimate_state, and use it
	to determine whether to call infer_loop_bounds_from_undefined
	and compute_estimated_nb_iterations.
	(n_of_executions_at_most): Use double_ints.
	(free_numbers_of_iterations_estimates_loop): Set estimate_state.
	(substitute_in_loop_info): Do not replace in estimated_nb_iterations.
	* double-int.c (double_int_to_tree): Improve comment.
	(double_int_fits_to_tree_p): New function.
	* double-int.h (double_int_fits_to_tree_p): Declare.
	* tree-data-ref.c: Include langhooks.h.
	(estimate_niter_from_size_of_data, estimate_iters_using_array): Removed.
	(analyze_array_indexes): Do not call estimate_niter_from_size_of_data.
	(analyze_array): Do not pass estimate_only argument to
	analyze_array_indexes.
	(get_number_of_iters_for_loop): Build tree from the stored double_int
	value.
	(get_references_in_stmt, find_data_references_in_stmt): New functions.
	(find_data_references_in_loop): Use find_data_references_in_stmt.
	* tree-data-ref.h (struct data_ref_loc_d): New.
	(get_references_in_stmt): Declare.
	(estimate_iters_using_array): Declaration removed.
	* cfgloop.h (struct nb_iter_bound): Change type of bound to
	double_int.  Improve comments.  Add is_exit and realistic
	fields.
	(struct loop): Changed type of estimated_nb_iterations to double_int.
	Added estimate_state field.
	(record_estimate): Declaration removed.

From-SVN: r118729
parent 47eb5b32
2006-11-12 Zdenek Dvorak <dvorakz@suse.cz>
* Makefile.in (tree-data-ref.o): Add langhooks.h dependency.
* tree-ssa-loop-niter.c (derive_constant_upper_bound): Follow
ud-chains. Handle AND_EXPR.
(record_estimate): Record whether the estimate is realistic
and whether it is derived from a loop exit.
(record_nonwrapping_iv, idx_infer_loop_bounds, infer_loop_bounds_from_ref,
infer_loop_bounds_from_array, infer_loop_bounds_from_signedness): New
functions.
(compute_estimated_nb_iterations): Take only realistic bounds into
account. Set estimate_state. Use double_ints.
(infer_loop_bounds_from_undefined): Call infer_loop_bounds_from_array
and infer_loop_bounds_from_signedness. Do not consider basic blocks
that do not have to be always executed.
(estimate_numbers_of_iterations_loop): Set estimate_state, and use it
to determine whether to call infer_loop_bounds_from_undefined
and compute_estimated_nb_iterations.
(n_of_executions_at_most): Use double_ints.
(free_numbers_of_iterations_estimates_loop): Set estimate_state.
(substitute_in_loop_info): Do not replace in estimated_nb_iterations.
* double-int.c (double_int_to_tree): Improve comment.
(double_int_fits_to_tree_p): New function.
* double-int.h (double_int_fits_to_tree_p): Declare.
* tree-data-ref.c: Include langhooks.h.
(estimate_niter_from_size_of_data, estimate_iters_using_array): Removed.
(analyze_array_indexes): Do not call estimate_niter_from_size_of_data.
(analyze_array): Do not pass estimate_only argument to
analyze_array_indexes.
(get_number_of_iters_for_loop): Build tree from the stored double_int
value.
(get_references_in_stmt, find_data_references_in_stmt): New functions.
(find_data_references_in_loop): Use find_data_references_in_stmt.
* tree-data-ref.h (struct data_ref_loc_d): New.
(get_references_in_stmt): Declare.
(estimate_iters_using_array): Declaration removed.
* cfgloop.h (struct nb_iter_bound): Change type of bound to
double_int. Improve comments. Add is_exit and realistic
fields.
(struct loop): Changed type of estimated_nb_iterations to double_int.
Added estimate_state field.
(record_estimate): Declaration removed.
2006-11-12 Zdenek Dvorak <dvorakz@suse.cz>
* params.c (set_param_value): Initialize the "set" field.
* params.h (struct param_info): Add "set" field.
(PARAM_SET_P): New macro.
......
......@@ -2080,7 +2080,7 @@ tree-scalar-evolution.o: tree-scalar-evolution.c $(CONFIG_H) $(SYSTEM_H) \
tree-data-ref.o: tree-data-ref.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) \
$(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) $(CFGLOOP_H) \
$(TREE_DATA_REF_H) $(SCEV_H) tree-pass.h tree-chrec.h
$(TREE_DATA_REF_H) $(SCEV_H) tree-pass.h tree-chrec.h langhooks.h
tree-vect-analyze.o: tree-vect-analyze.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(GGC_H) $(OPTABS_H) $(TREE_H) $(BASIC_BLOCK_H) \
$(DIAGNOSTIC_H) $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) $(CFGLOOP_H) \
......
......@@ -47,12 +47,31 @@ struct lpt_decision
struct nb_iter_bound
{
tree bound; /* The constant expression whose value is an upper
bound on the number of executions of ... */
tree at_stmt; /* ... this statement during one execution of
a loop. */
/* The statement STMT is executed at most ... */
tree stmt;
/* ... BOUND + 1 times (BOUND must be an unsigned constant).
The + 1 is added for the following reasons:
a) 0 would otherwise be unused, while we would need to care more about
overflows (as MAX + 1 is sometimes produced as the estimate on number
of executions of STMT).
b) it is consistent with the result of number_of_iterations_exit. */
double_int bound;
/* True if the statement will cause the loop to be leaved the (at most)
BOUND + 1-st time it is executed, that is, all the statements after it
are executed at most BOUND times. */
bool is_exit;
/* True if the bound is "realistic" -- i.e., most likely the loop really has
number of iterations close to the bound. Exact bounds (if the number of
iterations of a loop is a constant) and bounds derived from the size of
data accessed in the loop are considered realistic. */
bool realistic;
/* The next bound in the list. */
struct nb_iter_bound *next;
/* The next bound in a list. */
};
/* Structure to hold information for each natural loop. */
......@@ -111,9 +130,18 @@ struct loop
information in this field. */
tree nb_iterations;
/* An INTEGER_CST estimation of the number of iterations. NULL_TREE
if there is no estimation. */
tree estimated_nb_iterations;
/* An integer estimation of the number of iterations. Estimate_state
describes what is the state of the estimation. */
enum
{
/* Estimate was not computed yet. */
EST_NOT_COMPUTED,
/* Estimate was computed, but we could derive no useful bound. */
EST_NOT_AVAILABLE,
/* Estimate is ready. */
EST_AVAILABLE
} estimate_state;
double_int estimated_nb_iterations;
/* Upper bound on number of iterations of a loop. */
struct nb_iter_bound *bounds;
......@@ -398,6 +426,5 @@ enum
extern void unroll_and_peel_loops (struct loops *, int);
extern void doloop_optimize_loops (struct loops *);
extern void move_loop_invariants (struct loops *);
extern void record_estimate (struct loop *, tree, tree, tree);
#endif /* GCC_CFGLOOP_H */
......@@ -290,7 +290,8 @@ double_int_umod (double_int a, double_int b, unsigned code)
return double_int_mod (a, b, true, code);
}
/* Constructs tree in type TYPE from with value given by CST. */
/* Constructs tree in type TYPE from with value given by CST. Signedness of CST
is assumed to be the same as the signedness of TYPE. */
tree
double_int_to_tree (tree type, double_int cst)
......@@ -300,6 +301,19 @@ double_int_to_tree (tree type, double_int cst)
return build_int_cst_wide (type, cst.low, cst.high);
}
/* Returns true if CST fits into range of TYPE. Signedness of CST is assumed
to be the same as the signedness of TYPE. */
bool
double_int_fits_to_tree_p (tree type, double_int cst)
{
double_int ext = double_int_ext (cst,
TYPE_PRECISION (type),
TYPE_UNSIGNED (type));
return double_int_equal_p (cst, ext);
}
/* Returns true if CST is negative. Of course, CST is considered to
be signed. */
......
......@@ -58,7 +58,8 @@ union tree_node;
/* Constructors and conversions. */
union tree_node *double_int_to_tree (union tree_node *, double_int);
double_int tree_to_double_int (union tree_node *tree);
bool double_int_fits_to_tree_p (union tree_node *, double_int);
double_int tree_to_double_int (union tree_node *);
/* Constructs double_int from integer CST. The bits over the precision of
HOST_WIDE_INT are filled with the sign bit. */
......
......@@ -269,6 +269,21 @@ DEF_VEC_ALLOC_P(ddr_p,heap);
/* Describes a location of a memory reference. */
typedef struct data_ref_loc_d
{
/* Position of the memory reference. */
tree *pos;
/* True if the memory reference is read. */
bool is_read;
} data_ref_loc;
DEF_VEC_O (data_ref_loc);
DEF_VEC_ALLOC_O (data_ref_loc, heap);
bool get_references_in_stmt (tree, VEC (data_ref_loc, heap) **);
extern tree find_data_references_in_loop (struct loop *,
VEC (data_reference_p, heap) **);
extern void compute_data_dependences_for_loop (struct loop *, bool,
......@@ -292,7 +307,6 @@ extern void free_dependence_relation (struct data_dependence_relation *);
extern void free_dependence_relations (VEC (ddr_p, heap) *);
extern void free_data_refs (VEC (data_reference_p, heap) *);
extern struct data_reference *analyze_array (tree, tree, bool);
extern void estimate_iters_using_array (tree, tree);
/* Return the index of the variable VAR in the LOOP_NEST array. */
......
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