Commit Graph

48 Commits

Author SHA1 Message Date
Zdenek Dvorak a6f778b21e re PR tree-optimization/18527 (cannot determine number of iterations for loops with <=)
PR tree-optimization/18527
	* tree-ssa-loop-niter.c (number_of_iterations_cond,
	number_of_iterations_special, number_of_iterations_exit):
	Move base and step of an iv to a single structure.  Add
	no_overflow flag, and use it in # of iterations analysis.
	* tree-scalar-evolution.c (analyze_scalar_evolution_in_loop): Add
	folded_casts argument.
	(simple_iv): Pass base and step in a structure.  Set no_overflow
	flag.
	(scev_const_prop): Add argument to analyze_scalar_evolution_in_loop.
	Evaluate expensiveness of computing # of iterations instead of
	the final expression.
	* tree-scalar-evolution.h (affine_iv): New structure.
	(simple_iv): Declaration changed.
	* tree-chrec.c (chrec_apply): Handle chrecs containing symbols.
	* tree-ssa-loop-ivopts.c (determine_biv_step, find_givs_in_stmt_scev,
	find_givs_in_stmt): Changed due to simple_iv change.

	* gcc.dg/tree-ssa/loop-15.c: New test.

From-SVN: r109427
2006-01-06 20:22:56 +00:00
Richard Guenther 8d66aecaff tree-flow.h (ref_contains_indirect_ref): Rename to array_ref_contains_indirect_ref.
2005-11-04  Richard Guenther  <rguenther@suse.de>

	* tree-flow.h (ref_contains_indirect_ref): Rename to
	array_ref_contains_indirect_ref.
	* tree-flow-inline.h (ref_contains_indirect_ref): Likewise.
	(array_ref_contains_indirect_ref): Make comment match the code
	and vice-versa.
	(ref_contains_array_ref): Likewise.
	* tree-ssa-structalias.c (find_func_aliases): Remove call to
	ref_contains_indirect_ref.
	* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
	Rename calls to ref_contains_indirect_ref.

From-SVN: r106499
2005-11-04 18:02:51 +00:00
Zdenek Dvorak c9639aaea9 re PR tree-optimization/24226 (ICE: Segmentation fault in operand_equal_p (complete loop unrolling))
PR tree-optimization/24226
	* tree-cfg.c (remove_bb): Clean up unreachable loops.
	* tree-flow.h (free_numbers_of_iterations_estimates_loop): Declare.
	* tree-ssa-loop-niter.c (free_numbers_of_iterations_estimates_loop):
	Export.

From-SVN: r105151
2005-10-09 22:50:01 +00:00
Daniel Berlin 8ec88e19de Add missing part of committed patch from 21st
From-SVN: r104696
2005-09-27 15:33:51 +00:00
Jakub Jelinek 6fff260313 re PR tree-optimization/23929 (segfault in expand_simple_operations, tree-ssa-loop-niter.c:637)
PR tree-optimization/23929
	* tree-ssa-loop-niter.c (expand_simple_operations): Return immediately
	if expr is NULL.

	* gcc.c-torture/compile/pr23929.c: New test.

From-SVN: r104461
2005-09-20 21:10:44 +02:00
Daniel Berlin 14b33c04a1 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
2005-09-15 17:21:48 +00:00
Sebastian Pop 18aed06a02 Makefile.in (tree-chrec.o): Depends on SCEV_H.
* Makefile.in (tree-chrec.o): Depends on SCEV_H.
	* tree-chrec.c: Include tree-scalar-evolution.h.
	(chrec_convert): Instantiate the base and step before calling
	scev_probably_wraps_p that would fail on parametric evolutions.
	Collect all the fails into a single section failed_to_convert,
	print a diagnostic, and return chrec_dont_know instead of calling
	fold_convert.
	* tree-scalar-evolution.c (loop_closed_phi_def): New.
	(instantiate_parameters_1): Avoid instantiation of loop closed ssa
	phi nodes.
	(scev_const_prop): Don't replace the definition of a loop closed ssa
	phi node by itself, or by another loop closed ssa phi node.
	* tree-ssa-loop-niter.c (scev_probably_wraps_p, convert_step): Check
	that base and step are defined.

From-SVN: r104092
2005-09-09 10:56:41 +00:00
Sebastian Pop ab02cc4e2c re PR middle-end/23410 (FAIL: gcc.c-torture/execute/950612-1.c execution, at -Os and -O3)
PR tree-optimization/23410
	* tree-ssa-loop-niter.c (scev_probably_wraps_p): Check that the
	sequence is not wrapping during the first step.

From-SVN: r103733
2005-09-01 15:09:41 +00:00
Sebastian Pop ce8f9416be re PR tree-optimization/23511 (Segfault in fold_binary)
PR tree-optimization/23511
	* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined): Don't
	handle cases where TYPE_MIN_VALUE or TYPE_MAX_VALUE are NULL_TREE.

From-SVN: r103391
2005-08-23 08:15:13 +00:00
Sebastian Pop a1596edc4b re PR tree-optimization/23434 (ICE: Segmentation fault compiling gsl1.5 at -O2)
PR tree-optimization/23434
        * tree-ssa-loop-niter.c (proved_non_wrapping_p): Give up when
        the iteration bound is not an INTEGER_CST.

From-SVN: r103315
2005-08-21 10:48:23 +00:00
James A. Morrison f457cf402e fold-const.c (optimize_bit_field_compare): Remove extra fold call.
2005-08-16  James A. Morrison  <phython@gcc.gnu.org>

        * fold-const.c (optimize_bit_field_compare): Remove extra fold call.
        (try_move_mult_to_index): Call fold_build2 instead of build2.
        (fold_binary): Don't call fold after calls to try_move_mult_to_index.
        * tree-ssa-loop-niter.c (inverse): Call int_const_binop instead of
        fold_binary_to_constant.
        (infer_loop_bounds_from_undefined): Call fold_build2 instead of
        fold (build.
        * tree-data-ref.c (tree_fold_divides_p): Use tree_int_cst_equal to
        check if A == gcd (A, B).  Remove TYPE argument.
        (analyze_offset) Use fold_build2 instead of fold (build.
        (create_data_ref): Likewise.
        (analyze_siv_subscript_cst_affine): Update calls to tree_fold_divides_p.        * tree-ssa-ccp.c (widen_bitfield): Call fold_build2 instead of build2
        then fold.

From-SVN: r103200
2005-08-17 03:56:20 +00:00
Sebastian Pop 546ad2d9fc * tree-ssa-loop-niter.c (scev_probably_wraps_p): Reword a comment.
From-SVN: r103152
2005-08-16 09:41:33 +00:00
Sebastian Pop d77704579c re PR tree-optimization/22236 (wrong code for casts and scev)
PR tree-optimization/22236
	* tree-cfg.c (print_pred_bbs, print_succ_bbs): Correctly print
	successors and predecessors.
	* tree-chrec.c (chrec_convert): Before converting, check that
	sequences don't wrap.
	* tree-data-ref.c (compute_estimated_nb_iterations): Moved ...
	(analyze_array): Extern.
	(find_data_references_in_loop): Remove call to
	compute_estimated_nb_iterations.
	* tree-data-ref.h (analyze_array): Declared.
	* tree-flow-inline.h (single_ssa_tree_operand, single_ssa_use_operand,
	single_ssa_def_operand, zero_ssa_operands): Fix documentation.
	* tree-flow.h (scev_probably_wraps_p): Declare with an extra parameter.
	* tree-scalar-evolution.c (instantiate_parameters_1): Factor entry
	condition.
	* tree-ssa-loop-ivcanon.c: Fix documentation.
	* tree-ssa-loop-ivopts.c (idx_find_step): Add a fixme note.
	* tree-ssa-loop-niter.c (compute_estimated_nb_iterations): ... here.
	(infer_loop_bounds_from_undefined): New.
	(estimate_numbers_of_iterations_loop): Use
	infer_loop_bounds_from_undefined.
	(used_in_pointer_arithmetic_p): New.
	(scev_probably_wraps_p): Pass an extra parameter.  Call
	used_in_pointer_arithmetic_p.  Check that AT_STMT is not null.
	(convert_step): Fix documentation.
	* tree-vrp.c (adjust_range_with_scev): Call instantiate_parameters.
	Use initial_condition_in_loop_num and evolution_part_in_loop_num
	instead of CHREC_LEFT and CHREC_RIGHT.  Adjust the call to
	scev_probably_wraps_p.

From-SVN: r103055
2005-08-13 17:28:43 +00:00
James A. Morrison 2f133f4681 tree-ssa-loop-niter.c (tree_simplify_using_condition_1): Use fold_binary instead of fold_build2 since we don't care about the resulting tree.
2005-08-09  James A. Morrison  <phython@gcc.gnu.org>

        * tree-ssa-loop-niter.c (tree_simplify_using_condition_1): Use
        fold_binary instead of fold_build2 since we don't care about the
        resulting tree.
        (loop_niter_by_eval): Likewise.
        (compare_trees): Likewise.
        (proved_non_wrapping_p): Likewise.

From-SVN: r102897
2005-08-09 04:24:56 +00:00
Zdenek Dvorak 26c406400e re PR tree-optimization/22348 (Execution continues past end of for loop end condition with optimisation enabled)
PR tree-optimize/22348
	* tree-ssa-loop-niter.c (number_of_iterations_cond):
	Fold the partial computation.

	* gcc.c-torture/execute/pr22348.c: New.

From-SVN: r102427
2005-07-27 14:04:17 +00:00
Paolo Bonzini f9cc1a70d5 re PR rtl-optimization/19210 (not using do-loop for some loops)
gcc:
2005-07-21  Paolo Bonzini  <bonzini@gnu.org>
            Zdenek Dvorak  <dvorakz@suse.cz>

	PR tree-optimization/19210
	* common.opt (Wunsafe-loop-optimizations, funsafe-loop-optimizations):
	New.
	* Makefile.in (tree-ssa-loop-niter.o): Depend intl.o.
	* loop-iv.c (get_simple_loop_desc): If -funsafe-loop-optimizations,
	rely on unproven assumptions.
	* predict.c (predict_loops): Adjust call to number_of_iterations_exit.
	* tree-flow.h (number_of_iterations_exit): Add final parameter.
	* tree-scalar-evolution.c (number_of_iterations_in_loop): Adjust call
	to number_of_iterations_exit.
	* tree-ssa-loop-ivcanon.c (empty_loop_p): Likewise.
	* tree-ssa-loop-ivopts.c (niter_for_exit): Likewise.
	* tree-ssa-loop-niter.c (find_loop_niter,
	estimate_numbers_of_iterations_loop): Likewise.
	(number_of_iterations_exit): Honor the new options.
	* doc/invoke.texi (Wunsafe-loop-optimizations,
	funsafe-loop-optimizations): Document them.

gcc/testsuite:
2005-07-21  Paolo Bonzini  <bonzini@gnu.org>

        * gcc.dg/tree-ssa/pr19210-1.c: New.
        * gcc.dg/tree-ssa/pr19210-2.c: New.

Co-Authored-By: Zdenek Dvorak <dvorakz@suse.cz>

From-SVN: r102225
2005-07-21 07:24:34 +00:00
Diego Novillo 3eca1bd776 re PR tree-optimization/21959 (vrp miscompiles Ada front-end, drops loop exit test in well-defined wrap-around circumstances)
PR 21959
	* tree-ssa-loop-niter.c (scev_probably_wraps_p): Handle type
	casts between unsigned and signed types with different size
	or precision.

testsuite/ChangeLog

	PR 21959
	* gcc.dg/tree-ssa/pr21959.c: New test.

From-SVN: r101365
2005-06-27 20:52:35 -04:00
Kelley Cook 366ccddb2b Update FSF address.
From-SVN: r101317
2005-06-25 02:02:01 +00:00
Sebastian Pop 79ebd55c85 tree-data-ref.c (compute_estimated_nb_iterations, [...]): Fixed to use chrec_contains_undetermined to test the values of...
* tree-data-ref.c (compute_estimated_nb_iterations,
	analyze_array_indexes, compute_overlap_steps_for_affine_1_2,
	analyze_subscript_affine_affine, find_data_references_in_loop):
	Fixed to use chrec_contains_undetermined to test the values of
	loop->estimated_nb_iterations.
	* tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop):
	Compute the estimation only when loop->estimated_nb_iterations
	has not yet been initialized.
	(convert_step_widening, scev_probably_wraps_p): Add a call to
	estimate_numbers_of_iterations_loop.
	* tree-vrp.c (execute_vrp): Don't call estimate_numbers_of_iterations.

From-SVN: r100749
2005-06-08 08:47:05 +00:00
Sebastian Pop 1e8552ebb2 Fixes PR 18403 and meta PR 21861.
* Makefile.in (tree-chrec.o): Depend on CFGLOOP_H and TREE_FLOW_H.
	* tree-chrec.c: Include cfgloop.h and tree-flow.h.
	(evolution_function_is_invariant_rec_p,
	evolution_function_is_invariant_p): New.
	(chrec_convert): Use an extra parameter AT_STMT for refining the
	information that is passed down to convert_step.  Integrate the
	code that was in count_ev_in_wider_type.
	* tree-chrec.h (count_ev_in_wider_type): Removed.
	(chrec_convert): Modify its declaration.
	(evolution_function_is_invariant_p): Declared.
	(evolution_function_is_affine_p): Use evolution_function_is_invariant_p.
	* tree-flow.h (can_count_iv_in_wider_type): Renamed convert_step.
	(scev_probably_wraps_p): Declared.
	* tree-scalar-evolution.c (count_ev_in_wider_type): Removed.
	(follow_ssa_edge_in_rhs, interpret_rhs_modify_expr):
	Use an extra parameter AT_STMT for refining the information that is
	passed down to convert_step.
	(follow_ssa_edge_inner_loop_phi, follow_ssa_edge,
	analyze_scalar_evolution_1): Initialize AT_STMT with the current
	analyzed statement.
	(instantiate_parameters_1): Don't know yet how to initialize AT_STMT.
	* tree-ssa-loop-ivopts.c (idx_find_step): Update the use of
	can_count_iv_in_wider_type to use convert_step.
	* tree-ssa-loop-niter.c (can_count_iv_in_wider_type_bound): Move
	code that is independent of the loop over the known iteration
	bounds to convert_step_widening, the rest is moved to
	proved_non_wrapping_p.
	(scev_probably_wraps_p): New.
	(can_count_iv_in_wider_type): Renamed convert_step.
	* tree-vrp.c (adjust_range_with_scev): Take an extra AT_STMT parameter.
	Use scev_probably_wraps_p for computing init_is_max.
	(vrp_visit_assignment): Pass the current analyzed statement to
	adjust_range_with_scev.
	(execute_vrp): Call estimate_numbers_of_iterations for refining the
	information provided by scev analyzer.

testsuite:

	* testsuite/gcc.dg/vect/vect-77.c: Remove xfail from lp64.
	* testsuite/gcc.dg/vect/vect-78.c: Same.

From-SVN: r100718
2005-06-07 19:51:25 +00:00
Zdenek Dvorak d5ab567508 re PR middle-end/21846 (segfault in fold_binary compiling vpr with -O2 -funroll-loops)
PR tree-optimization/21846
	* tree-cfg.c (replace_uses_by): Update information stored at loops.
	* tree-flow.h (substitute_in_loop_info): Declare.
	* tree-scalar-evolution.c (initialize_scalar_evolutions_analyzer):
	Ensure that chrec_dont_know and chrec_known have a type.
	* tree-ssa-loop-niter.c (substitute_in_loop_info): New function.

From-SVN: r100631
2005-06-05 18:07:43 +00:00
Zdenek Dvorak d7bf3bcf99 tree-ssa-loop-ivopts.c (find_bivs, [...]): Apply expand_simple_operations to bases of the ivs.
* tree-ssa-loop-ivopts.c (find_bivs, find_givs_in_stmt_scev): Apply
	expand_simple_operations to bases of the ivs.
	(tree_int_cst_sign_bit): Export.
	* tree-flow.h (expand_simple_operations): Declare.
	* tree-ssa-loop-niter.c (number_of_iterations_cond): Use
	tree_int_cst_sign_bit.
	(expand_simple_operations): Export.
	* tree.h (tree_int_cst_sign_bit): Declare.

From-SVN: r99853
2005-05-17 20:02:56 +00:00
Andrew MacLeod f47c96aac5 lambda-code.c (gcc_loop_to_lambda_loop, [...]): Use generic operand interface.
2005-05-03  Andrew MacLeod  <amacleod@redhat.com>

	* lambda-code.c (gcc_loop_to_lambda_loop,
	lambda_loopnest_to_gcc_loopnest, phi_loop_edge_uses_def,
	stmt_is_bumper_for_loop, perfect_nest_p, replace_uses_of_x_with_y): Use
	generic operand interface.
	* tree-data-ref.c (find_data_references_in_loop): Use generic interface.
	* tree-dfa.c (collect_dfa_stats_r, mark_new_vars_to_rename): Use
	generic operand interface.
	* tree-flow-inline.h (delink_imm_use, link_imm_use_to_list,
	link_imm_use, link_imm_use_stmt, relink_imm_use, relink_imm_use_stmt,
	next_safe_imm_use, has_zero_uses, has_single_use, single_imm_use,
	num_imm_uses): Use ssa_use_operand_t.
	(get_def_ops, get_use_ops, get_v_may_def_ops, get_vuse_ops,
	get_v_must_def_ops): Delete.
	(get_def_from_ptr, get_phi_result_ptr): Get def directly now.
	(get_use_op_ptr, get_def_op_ptr, get_v_may_def_result_ptr,
	get_v_may_def_op_ptr, get_vuse_op_ptr, get_v_must_def_result_ptr,
	get_v_must_def_kill_ptr): Delete.
	(delink_stmt_imm_use): Move and use new operand interface.
	(op_iter_next_use, op_iter_next_def, op_iter_next_tree, op_iter_init,
	op_iter_next_tree): Use new operand implementation.
	(clear_and_done_ssa_iter): New.  Initialize a blank operand iterator.
	(op_iter_init_use, op_iter_init_def, op_iter_init_tree): Add iterator
	type check.
	(op_iter_next_mustdef, op_iter_next_maydef,
	op_iter_next_must_and_may_def): Delete. Replace with...
	(op_iter_next_maymustdef): New.  Combine must and may next operations.
	(op_iter_init_maydef, op_iter_init_mustdef,
	op_iter_init_must_and_may_def): Use new interface.
	(single_ssa_tree_operand ): New.  Process single operands only as trees.
	(single_ssa_use_operand): New.  Process single operands only as uses.
	(single_ssa_def_operand): New.  Process single operands only as defs.
	(zero_ssa_operands): New.  Return TRUE if there are zero operands of the
	specified types.
	(num_ssa_operands): New.  Count the number of specified operands.
	(compare_ssa_operands_equal): New.  Compare two statements' operands.
	(single_phi_def): New.  Return true if PHI has one def of the specified
	operand type.
	(op_iter_init_phiuse): New.  Initialize the iterator for PHI arguments.
	(op_iter_init_phidef): New.  Initialize the iterator for the PHI def.
	* tree-flow.h (struct immediate_use_iterator_d): Use ssa_use_operand_t.
	(struct stmt_ann_d): Operands field no longer require GTY().
	(vn_compute, vn_lookup_or_add, vn_add, vn_lookup): Change prototype.
	* tree-into-ssa.c (mark_def_sites): Use SSA_OP_VMUSTKILL.
	* tree-outof-ssa.c (check_replaceable, find_replaceable_in_bb,
	dump_replaceable_exprs, rewrite_trees): Use generic interface.
	* tree-phinodes.c (make_phi_node, release_phi_node, resize_phi_node):
	Use use_operand_p instead of ssa_imm_use_t *.
	* tree-pretty-print.c (dump_vops): check if operands are active before
	dumping virtual operands.
	* tree-sra.c (sra_walk_function): Use ZERO_SSA_OPERANDS.
	* tree-ssa-ccp.c (likely_value): Use ZERO_SSA_OPERANDS.
	(ccp_fold): Use new interface.
	(ccp_visit_stmt): Remove unused variables and code.
	(convert_to_gimple_builtin): Insert statements before calling
	mark_new_vars_to_rename.
	* tree-ssa-copy.c (stmt_may_generate_copy): Use ZERO_SSA_OPERANDS.
	(copy_prop_visit_cond_stmt): Use generic interface.
	* tree-ssa-dom.c (struct expr_hash_elt): Use stmt pointer, not the
	annotation in table.
	(thread_across_edge): Use generic interface.
	(initialize_hash_element): Initialzie with stmt, not annotation.
	(eliminate_redundant_computations): Use generic interface.
	(record_equivalences_from_stmt): Pass stmt, not annotation.
	(avail_expr_hash, real_avail_expr_hash, avail_expr_eq): Use generic
	interface.
	* tree-ssa-dse.c (dse_optimize_stmt): Use ZERO_SSA_OPERANDS.
	* tree-ssa-loop-ivopts.c (find_invariants_stmt,
	find_interesting_uses_stmt, protect_loop_closed_ssa_form_use): Use
	generic operand interface.
	* tree-ssa-loop-niter.c (chain_of_csts_start, get_val_for): Use generic
	interface.
	* tree-ssa-loop-unswitch.c (tree_may_unswitch_on): Use Generic operand
	Interface.
	* tree-ssa-operands.c (struct opbuild_list_d): New.  Operand build type.
	(build_defs, build_uses, build_v_may_defs, build_vuses,
	build_v_must_defs): Change type to struct opbuild_list_d.
	(ops_active): New.  Operands active boolean.
	(operand_memory, operand_memory_index): New.  Operand memory managers.
	(allocate_def_optype, allocate_use_optype, allocate_v_may_def_optype,
	allocate_vuse_optype, allocate_v_must_def_optype): Delete.
	(free_uses, free_defs, free_vuses, free_v_may_defs, free_v_must_defs):
	Change from functions to static variable list heads.
	(opbuild_initialize_virtual): New.  Initialize a virtual build list.
	(opbuild_initialize_real): New.  Initialize a virtual build list.
	(opbuild_free): New.  Free a build list.
	(opbuild_num_elems): New.  Number of items in a list.
	(opbuild_append_real): New.  Add a real (tree *) operand.
	(opbuild_append_virtual): New.  Add and sort a virtual (tree) operand.
	(opbuild_first): New.  Return first element index in a list.
	(opbuild_next): New.  Return next element in a list.
	(opbuild_elem_real): New.  Return real element.
	(opbuild_elem_virtual): New.  Return virtual element.
	(opbuild_elem_uid): New.  Return UID of virtual element.
	(opbuild_clear): New.  Reset an operand list.
	(opbuild_remove_elem): New.  Remove an element form a list.
	(ssa_operands_active): New.  Return true if operand cache is active.
	(init_ssa_operands, fini_ssa_operands): Initialize new implementation.
	(ssa_operand_alloc): New.  Allocate memory from an operand chunk.
	(correct_use_link): Use use_operand_p.
	(finalize_ssa_uses, finalize_ssa_v_may_defs, finalize_ssa_defs,
	finalize_ssa_vuses, finalize_ssa_v_must_defs): New implmentation.
	(cleanup_v_may_defs): Use new implmentation.
	(finalize_ssa_stmt_operands, start_ssa_stmt_operands): New
	implementation.
	(append_def, append_use, append_v_may_def, append_vuse,
	append_v_must_def): Call opbuild_append routine instead of using varray.
	(build_ssa_operands): Simplify to simply use stmt, don't maintain a
	global parse_old_ops variable.
	(free_ssa_operands): New implementation.
	(update_stmt_operands): Move.  Change argument to build_ssa_operands.
	(copy_virtual_operands): Move. New generic implementation.
	(create_ssa_artficial_load_stmt): Move. New implementation.
	(swap_tree_operands): Update for new implementation.
	(get_expr_operands): Add stmt parameter to calls to swap_tree_operands.
	(add_call_clobber_ops, add_call_read_ops): Initialize opbuild list
	rather than a varray.
	(verify_imm_links): Use use_operand_p.
	(dump_immediate_uses_for): If the immediate use variable is a virtual
	variable, show the virtual ops in the stmt.
	* tree-ssa-operands.h (def_operand_p): No longer a structure.
	(NULL_DEF_OPERAND_P): Now a #define.
	(def_optype_d, use_optype_d, v_def_use_operand_type, v_may_def_optype_d,
	vuse_operand_type, vuse_optype_d, v_must_def_optype_d): Delete.
	(def_optype_d, use_optype_d, maydef_optype_d, vuse_optype_d,
	mustdef_optype_d): New.  Use Linked list representation.
	(SSA_OPERAND_MEMORY_SIZE): New.  Size of operand memory chunk.
	(struct ssa_operand_memory_d): New.  Allocated Chunk node.
	(struct stmt_operands_d): Change to new pointers that are not GTY.
	(STMT_USE_OPS, NUM_USES, SET_USE_OP, STMT_DEF_OPS, NUM_DEFS, SET_DEF_OP,
	STMT_V_MAY_DEF_OPS, NUM_V_MAY_DEFS, SET_V_MAY_DEF_RESULT,
	SET_V_MAY_DEF_OP, STMT_VUSE_OPS, NUM_VUSES, SET_VUSE_OP,
	STMT_V_MUST_DEF_OPS, NUM_V_MUST_DEFS, SET_V_MUST_DEF_RESULT,
	SET_V_MUST_DEF_KILL): Delete.
	(V_MAY_DEF_OPS, V_MAY_DEF_RESULT_PTR, V_MAY_DEF_RESULT,
	V_MAY_DEF_OP_PTR, V_MAY_DEF_OP): Rename to MAYDEF_*.
	(V_MUST_DEF_OPS, V_MUST_DEF_RESULT_PTR, V_MUST_DEF_RESULT,
	V_MUST_DEF_KILL_PTR, V_MUST_DEF_KILL): Rename to MUSTDEF_*.
	(enum ssa_op_iter_type): Operand iterator typechecking values.
	(struct ssa_operand_iterator_d): Use linked lists of operands.
	(SSA_OP_VMUSTDEFKILL): Rename to SSA_OP_VMUSTKILL.
	(FOR_EACH_SSA_MAYDEF_OPERAND, FOR_EACH_SSA_MUSTDEF_OPERAND,
	FOR_EACH_SSA_MUST_AND_MAY_DEF_OPERAND): Use op_iter_next_maymustdef.
	(FOR_EACH_PHI_ARG): New.  Iterate over PHI arguments.
	(FOR_EACH_PHI_OR_STMT_USE): New.  Iterate over PHI or stmt uses.
	(FOR_EACH_PHI_OR_STMT_DEF): New.  Iterate over PHI or stmt defs.
	(SINGLE_SSA_TREE_OPERAND, SINGLE_SSA_USE_OPERAND,
	SINGLE_SSA_DEF_OPERAND, ZERO_SSA_OPERANDS, NUM_SSA_OPERANDS): New.
	* tree-ssa-opfinalize.h: New.  Function templates for expansion.
	(FINALIZE_ALLOC): Expands into alloc_def, alloc_use, alloc_maydef,
	alloc_vuse, and alloc_mustdef.
	(FINALIZE_FUNC): Expands into finalize_ssa_def_ops,
	finalize_ssa_use_ops, finalize_ssa_v_may_def_ops, finalize_ssa_vuse_ops,
	and finalize_ssa_v_must_def_ops.
	* tree-ssa-pre.c (add_to_sets): Pass tree to vn_add.
	(create_value_expr_from): Use stmt not vuse_optype as a parameter. Pass
	stmt around.
	(compute_avail): Use generic iterator interface.
	* tree-ssa-propagate.c (first_vdef): Use generic operand interface.
	(stmt_makes_single_load, stmt_makes_single_store): Use
	ZERO_SSA_OPERANDS.
	* tree-ssa-sink.c (is_hidden_global_store): Use ZERO_SSA_OPERANDS.
	(statement_sink_location): Use generic interface.
	* tree-ssa.c (verify_ssa):  Use %p in fprintf.  Use generic interface.
	(delete_tree_ssa): Don't call release_defs.  Call release_ssa_name and
	reset the immediate use link nodes.
	(stmt_references_memory_p): Use ZERO_SSA_OPERANDS.
	* tree-ssanames.c (make_ssa_name): Use use_operand_p.
	* tree-tailcall.c (find_tail_calls): Use ZERO_SSA_OPERANDS.
	(eliminate_tail_call): Use generic operand interface.
	* tree-vect-analyze.c (vect_analyze_data_refs): Use ZERO_SSA_OPERANDS.
	(vect_mark_relevant, vect_mark_stmts_to_be_vectorized): Use generic
	interface.
	* tree-vect-transform.c (update_vuses_to_preheader): Use generic
	interface.
	* tree-vectorizer.c (rename_variables_in_bb): Use generic interface.
	* tree-vn.c (struct val_expr_pair_d): Cache statment pointer instead of
	vuse_optype.
	(vn_compute, val_expr_pair_hash, vn_add, vn_lookup, vn_lookup_or_add):
	Use statement pointer instead of vuse_optype.  Use generic interface.
	* tree-vrp.c (maybe_add_assert_expr): Use generic interface.
	(stmt_interesting_for_vrp, vrp_visit_stmt): Use ZERO_SSA_OPERANDS.
	* tree.h (struct ssa_imm_use_d): Renamed to ssa_use_operand_d.
	(tree_ssa_name, phi_arg_d): Use ssa_use_operand_d.
	* doc/tree-ssa.texi: Update documentation for operand interface.

From-SVN: r99155
2005-05-03 12:19:56 +00:00
Zdenek Dvorak 9be872b77b re PR tree-optimization/18316 (Missed IV optimization)
PR tree-optimization/18316
	PR tree-optimization/19126
	* tree.c (build_int_cst_type): Avoid shift by size of type.
	* tree-scalar-evolution.c (simple_iv): Add allow_nonconstant_step
	argument.
	* tree-scalar-evolution.h (simple_iv): Declaration changed.
	* tree-ssa-loop-ivopts.c (struct iv_cand): Add depends_on
	field.
	(dump_cand): Dump depends_on information.
	(determine_biv_step): Add argument to simple_iv call.
	(contains_abnormal_ssa_name_p): Handle case expr == NULL.
	(find_bivs, find_givs_in_stmt_scev): Do not require step to be a
	constant.
	(add_candidate_1): Record depends_on for candidates.
	(tree_int_cst_sign_bit, constant_multiple_of): New functions.
	(get_computation_at, get_computation_cost_at, may_eliminate_iv):
	Handle ivs with nonconstant step.
	(iv_ca_set_remove_invariants, iv_ca_set_add_invariants): New functions.
	(iv_ca_set_no_cp, iv_ca_set_cp): Handle cand->depends_on.
	(create_new_iv): Unshare the step before passing it to create_iv.
	(free_loop_data): Free cand->depends_on.
	(build_addr_strip_iref): New function.
	(find_interesting_uses_address): Use build_addr_strip_iref.
	(strip_offset_1): Split the recursive part from strip_offset.
	Strip constant offset component_refs and array_refs.
	(strip_offset): Split the recursive part to strip_offset_1.
	(add_address_candidates): Removed.
	(add_derived_ivs_candidates): Do not use add_address_candidates.
	(add_iv_value_candidates): Add candidates with stripped constant
	offset.  Consider all candidates with initial value 0 important.
	(struct affine_tree_combination): New.
	(aff_combination_const, aff_combination_elt, aff_combination_scale,
	aff_combination_add_elt, aff_combination_add,
	tree_to_aff_combination, add_elt_to_tree, aff_combination_to_tree,
	fold_affine_sum): New functions.
	(get_computation_at): Use fold_affine_sum.
	* tree-ssa-loop-manip.c (create_iv): Handle ivs with nonconstant step.
	* tree-ssa-loop-niter.c (number_of_iterations_exit): Add argument
	to simple_iv call.

	* gcc.dg/tree-ssa/loop-8.c: New test.

From-SVN: r99059
2005-05-01 08:08:14 +00:00
Zdenek Dvorak be1b5cba35 tree-ssa-loop-niter.c (tree_simplify_using_condition): Expand simple definitions of ssa names in condition.
* tree-ssa-loop-niter.c (tree_simplify_using_condition): Expand simple
	definitions of ssa names in condition.  Split recusive part to ...
	(tree_simplify_using_condition_1): New function.
	(expand_simple_operations): New function.

	* gcc.dg/vect/vect-99.c: New test.

From-SVN: r98635
2005-04-23 21:33:15 +00:00
Kazu Hirata 1e6a5d3c8f tree-flow-inline.h (get_stmt_operands): Remove.
* tree-flow-inline.h (get_stmt_operands): Remove.
	* lambda-code.c, tree-ssa-loop-unswitch.c,
	tree-ssa-operands.c, tree-ssa-pre.c, tree-ssa-propagate.c,
	tree-ssa-sink.c, tree-ssa.c, tree-tailcall.c,
	tree-vect-transform.c, tree-vectorizer.c, tree-vrp.c): Remove
	calls to get_stmt_operands.
	* doc/tree-ssa.texi: Don't mention get_stmt_operands.

From-SVN: r98262
2005-04-17 06:42:03 +00:00
Zdenek Dvorak c33e657d34 tree-flow.h (number_of_iterations_cond): Declaration removed.
* tree-flow.h (number_of_iterations_cond): Declaration removed.
	* tree-ssa-loop-niter.c (number_of_iterations_cond): Made static.
	(number_of_iterations_special): New function.
	(number_of_iterations_exit): Use number_of_iterations_special.
	Use simplify_using_outer_evolutions only at -O3.
	(number_of_iterations_cond, tree_simplify_using_condition,
	simplify_using_initial_conditions, loop_niter_by_eval,
	compare_trees, can_count_iv_in_wider_type_bound,
	simplify_using_outer_evolutions): Use fold_build.

From-SVN: r97673
2005-04-05 23:52:41 +00:00
Zdenek Dvorak c5cbcccf90 basic-block.h (single_succ_p, [...]): New inline functions.
* basic-block.h (single_succ_p, single_pred_p, single_succ_edge,
	single_pred_edge, single_succ, single_pred): New inline functions.
	* bb-reorder.c (rotate_loop, find_traces_1_round,
	add_labels_and_missing_jumps, fix_up_fall_thru_edges,
	duplicate_computed_gotos): Use the single_succ/pred functions.
	* cfganal.c (forwarder_block_p): Ditto.
	* cfgbuild.c (compute_outgoing_frequencies): Ditto.
	* cfgcleanup.c (try_simplify_condjump, try_forward_edges,
	outgoing_edges_match, try_crossjump_to_edge, try_optimize_cfg,
	merge_seq_blocks): Ditto.
	* cfghooks.c (split_edge, tidy_fallthru_edges): Ditto.
	* cfglayout.c (fixup_reorder_chain): Ditto.
	* cfgloop.c (mark_single_exit_loops, update_latch_info,
	canonicalize_loop_headers, verify_loop_structure): Ditto.
	* cfgloopmanip.c (remove_path, unloop, loop_delete_branch_edge,
	mfb_update_loops, create_preheader, force_single_succ_latches,
	create_loop_notes): Ditto.
	* cfgrtl.c (rtl_can_merge_blocks, try_redirect_by_replacing_jump,
	force_nonfallthru_and_redirect, rtl_tidy_fallthru_edge,
	commit_one_edge_insertion, purge_dead_edges,
	cfg_layout_can_merge_blocks_p): Ditto.
	* except.c (sjlj_emit_function_enter): Ditto.
	* flow.c (init_propagate_block_info): Ditto.
	* function.c (thread_prologue_and_epilogue_insns): Ditto.
	* gcse.c (find_implicit_sets, bypass_conditional_jumps,
	insert_insn_end_bb): Ditto.
	* ifcvt.c (merge_if_block, find_if_block, find_if_case_1,
	find_if_case_2): Ditto.
	* lambda-code.c (perfect_nestify): Ditto.
	* lcm.c (optimize_mode_switching): Ditto.
	* loop-doloop.c (doloop_modify): Ditto.
	* loop-init.c (loop_optimizer_init): Ditto.
	* loop-iv.c (simplify_using_initial_values): Ditto.
	* loop-unroll.c (unroll_loop_runtime_iterations): Ditto.
	* loop-unswitch.c (unswitch_loop): Ditto.
	* modulo-sched.c (generate_prolog_epilog): Ditto.
	* predict.c (combine_predictions_for_insn, estimate_probability,
	tree_estimate_probability, last_basic_block_p,
	estimate_bb_frequencies): Ditto.
	* profile.c (branch_prob): Ditto.
	* regrename.c (copyprop_hardreg_forward): Ditto.
	* sched-rgn.c (is_cfg_nonregular, find_rgns, update_live): Ditto.
	* tracer.c (layout_superblocks): Ditto.
	* tree-cfg.c (tree_can_merge_blocks_p, tree_merge_blocks,
	cfg_remove_useless_stmts_bb, cleanup_control_flow,
	cleanup_control_expr_graph, disband_implicit_edges,
	tree_find_edge_insert_loc, bsi_commit_edge_inserts,
	tree_verify_flow_info, tree_make_forwarder_block,
	tree_forwarder_block_p, remove_forwarder_block,
	remove_forwarder_block_with_phi, merge_phi_nodes): Ditto.
	* tree-if-conv.c (tree_if_conversion): Ditto.
	* tree-mudflap.c (mf_build_check_statement_for): Ditto.
	* tree-ssa-dce.c (remove_dead_stmt): Ditto.
	* tree-ssa-dom.c (dom_opt_finalize_block): Ditto.
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p,
	copy_loop_headers): Ditto.
	* tree-ssa-loop-im.c (loop_commit_inserts): Ditto.
	* tree-ssa-loop-ivopts.c (compute_phi_arg_on_exit): Ditto.
	* tree-ssa-loop-manip.c (split_loop_exit_edge, ip_normal_pos,
	lv_adjust_loop_entry_edge, tree_ssa_loop_version): Ditto.
	* tree-ssa-loop-niter.c (simplify_using_initial_conditions): Ditto.
	* tree-ssa-loop-unswitch.c (simplify_using_entry_checks): Ditto.
	* tree-ssa-phiopt.c (tree_ssa_phiopt, value_replacement): Ditto.
	* tree-ssa-pre.c (compute_antic_aux, insert_aux, init_pre): Ditto.
	* tree-ssa-threadupdate.c (redirect_edges): Ditto.
	* tree-tailcall.c (independent_of_stmt_p, find_tail_calls,
	eliminate_tail_call, tree_optimize_tail_calls_1): Ditto.
	* tree-vect-analyze.c (vect_analyze_loop_form): Ditto.
	* tree-vect-transform.c (vect_update_ivs_after_vectorizer): Ditto.
	* tree-vectorizer.c (slpeel_update_phi_nodes_for_guard,
	slpeel_add_loop_guard): Ditto.

From-SVN: r96292
2005-03-11 09:05:12 +00:00
Kazu Hirata c486021de8 builtins.def, [...]: Update copyright.
* builtins.def, haifa-sched.c, libgcc2.c, libgcc2.h,
	tree-ssa-loop-ivcanon.c, tree-ssa-loop-niter.c,
	config/cris/cris-protos.h, config/cris/cris.c: Update
	copyright.

From-SVN: r94840
2005-02-10 18:59:07 +00:00
Zdenek Dvorak ca4c316991 re PR tree-optimization/18687 (>200% compile time regression compared to gcc-3.4)
PR tree-optimization/18687
	* tree-flow.h (find_loop_niter): Declare.
	* tree-ssa-loop-ivcanon.c (canonicalize_loop_induction_variables):
	Try using scev even for loops with more than one exit.
	* tree-ssa-loop-ivopts.c (struct loop_data): Removed niter field.
	(struct ivopts_data): Added niters field.
	(struct nfe_cache_elt): New.
	(nfe_hash, nfe_eq, niter_for_exit, niter_for_single_dom_exit): New
	functions.
	(tree_ssa_iv_optimize_init): Initialize niters cache.
	(determine_number_of_iterations): Removed.
	(find_induction_variables): Do not call determine_number_of_iterations.
	Access niters for single exit through niter_for_single_dom_exit.
	(add_iv_outer_candidates): Access niters for single exit through
	niter_for_single_dom_exit.
	(may_eliminate_iv): Take data argument.  Use niter_for_exit.  Do not use
	number_of_iterations_cond.
	(iv_period): New function.
	(determine_use_iv_cost_condition): Pass data to may_eliminate_iv.
	(may_replace_final_value): Take data argument.  Use
	niter_for_single_dom_exit.
	(determine_use_iv_cost_outer): Pass data to may_replace_final_value.
	(rewrite_use_compare): Pass data to may_eliminate_iv.
	(rewrite_use_outer): Pass data to may_replace_final_value.
	(free_loop_data): Clean up the niters cache.
	(tree_ssa_iv_optimize_finalize): Free the niters cache.
	(tree_ssa_iv_optimize_loop): Do not call loop_commit_inserts.
	* tree-ssa-loop-niter.c (find_loop_niter): New function.
	(find_loop_niter_by_eval): Use tree_int_cst_lt.
	(num_ending_zeros): Moved to tree.c.
	* tree.h (num_ending_zeros): Declare.
	* tree.c (num_ending_zeros): Moved from tree.c.

From-SVN: r94787
2005-02-10 00:32:47 +00:00
Roger Sayle b52d5eaa44 fold-const.c (nondestructive_fold_binary_to_constant): Rename to fold_binary_to_constant.
* fold-const.c (nondestructive_fold_binary_to_constant): Rename
	to fold_binary_to_constant.
	(nondestructive_fold_unary_to_constant): Likewise, rename to
	fold_unary_to_constant.
	(fold_relational_hi_lo): Update call to fold_binary_to_constant.
	* tree.h (nondestructive_fold_binary_to_constant): Update prototype.
	(nondestructive_fold_unary_to_constant): Likewise.
	* tree-ssa-ccp.c (ccp_fold): Update calls to fold_unary_to_constant
	and fold_binary_to_constant.
	* tree-ssa-loop-niter.c (EXEC_BINARY, EXEC_UNARY): Delete macros.
	(inverse, number_of_iterations_cond): Replace uses of EXEC_BINARY
	and EXEC_UNARY with calls to fold_*nary_to_constant.
	* tree-ssa-loop-ivopts.c (EXEC_BINARY, EXEC_UNARY): Delete macros.
	(idx_find_step): Replace uses of EXEC_BINARY with calls to
	fold_binary_to_constant.

From-SVN: r91063
2004-11-23 01:27:42 +00:00
Zdenek Dvorak 1d481ba83c re PR tree-optimization/18529 (When the lower bound of a loop is non-constant we cannot find the number of iterations)
PR tree-optimization/18529
	* fold-const.c (fold_to_nonsharp_ineq_using_bound): New function.
	(simple_operand_p): Use STRIP_NOPS.  Consider SSA names simple.
	(fold): Call fold_to_nonsharp_ineq_using_bound.
	* tree-ssa-loop-niter.c (simplify_replace_tree): New function.
	(number_of_iterations_cond): Fold the expressions before futher
	processing.
	(tree_simplify_using_condition): Handle case when cond or expr is
	an EQ_EXPR specially.

From-SVN: r91031
2004-11-22 21:33:47 +00:00
Zdenek Dvorak 18522563e0 re PR tree-optimization/18431 (Code for arrays and pointers are not the same)
PR tree-optimization/18431
	* fold-const.c (associate_trees): Do not produce x + 0.
	(fold_widened_comparison, fold_sign_changed_comparison): New functions.
	(fold): Use them.
	* tree-ssa-loop-niter.c (upper_bound_in_type, lower_bound_in_type):
	Moved ...
	* tree.c (upper_bound_in_type, lower_bound_in_type): Here.
	* tree.h (upper_bound_in_type, lower_bound_in_type): Declare.

	* testsuite/gcc.c-torture/execute/20041114-1.c: New test.

From-SVN: r90646
2004-11-15 00:18:37 +00:00
Kazu Hirata e1a8be3fb0 tree-ssa-loop-niter.c (upper_bound_in_type, [...]): Make them static.
* tree-ssa-loop-niter.c (upper_bound_in_type,
	lower_bound_in_type): Make them static.
	* tree.h: Remove the corresponding prototypes.

From-SVN: r90312
2004-11-08 22:38:12 +00:00
Zdenek Dvorak 38b0dcb81e re PR tree-optimization/18048 (mgrid loop performance regression with ivopts (register pressure))
PR tree-optimization/18048
	* fold-const.c (try_move_mult_to_index): New function.
	(fold): Use try_move_mult_to_index.
	* tree-ssa-loop-ivopts.c (try_add_cand_for): Prefer common candidates.
	* tree-ssa-loop-niter.c (number_of_iterations_cond): Produce
	an all-ones unsigned constant without extra bits.
	* tree.c (build_low_bits_mask): New function.
	* tree.h (build_low_bits_mask): Declare.

From-SVN: r89708
2004-10-27 20:27:20 +00:00
Kazu Hirata 471854f82a alias.c, [...]: Fix comment formatting.
* alias.c, basic-block.h, cgraphunit.c, combine.c, domwalk.h,
	final.c, gengtype.c, genpreds.c, ggc-page.c, insn-notes.def,
	lambda-code.c, loop-unroll.c, modulo-sched.c, pointer-set.c,
	pretty-print.c, ra-colorize.c, sbitmap.c, tree-complex.c,
	tree-data-ref.c, tree-dfa.c, tree-inline.c, tree-into-ssa.c,
	tree-scalar-evolution.c, tree-ssa-dom.c,
	tree-ssa-loop-manip.c, tree-ssa-loop-niter.c,
	tree-ssa-phiopt.c, tree-ssa-pre.c, tree-ssa-threadupdate.c,
	tree-vectorizer.c, vec.h: Fix comment formatting.

From-SVN: r89453
2004-10-22 17:05:11 +00:00
Zdenek Dvorak 26630a99da tree-ssa-loop-niter.c (inverse): Count in HOST_WIDE_INT if possible.
* tree-ssa-loop-niter.c (inverse): Count in HOST_WIDE_INT if possible.
	Use integer for loop counter.
	(num_ending_zeros): New function.
	(number_of_iterations_cond): Use num_ending_zeros.

From-SVN: r89438
2004-10-22 10:31:23 +00:00
Sebastian Pop 86df10e35e Makefile.in (tree-ssa-loop-niter.o): Depends on tree-data-ref.h.
2004-10-11  Sebastian Pop  <pop@cri.ensmp.fr>

	* Makefile.in (tree-ssa-loop-niter.o): Depends on tree-data-ref.h.
	* cfgloop.c (initialize_loops_parallel_p): New.
	(flow_loops_find): Initialize the parallel_p field to true for all
	the loops.
	* tree-ssa-loop-niter.c: Include "tree-data-ref.h".
	(estimate_numbers_of_iterations_loop): Infers the loop bounds from
	the size of the data accessed in the loop.
	(struct nb_iter_bound): Moved...
	* cfgloop.h (struct nb_iter_bound): ... here.
	(estimated_nb_iterations, parallel_p): New fields in struct loop.
	(record_estimate): Declare extern here.
	* tree-chrec.c: Fix comments.
	(nb_vars_in_chrec): New function.
	* tree-chrec.h (nb_vars_in_chrec): Declared here.
	* tree-data-ref.c: Don't include lambda.h, that is already included
	in tree-data-ref.h.
	(tree_fold_divides_p): Don't check for integer_onep.
	(tree_fold_bezout): Removed.
	(gcd): New static duplicated function.
	(int_divides_p, dump_subscript): New.
	(dump_data_dependence_relation): Use dump_subscript.
	(dump_dist_dir_vectors, dump_ddrs, compute_estimated_nb_iterations,
	estimate_niter_from_size_of_data): New.
	(analyze_array_indexes, analyze_array): Call
	estimate_niter_from_size_of_data during	the detection of array
	references.  Pass in a pointer to the statement that contains the
	array reference.
	(all_chrecs_equal_p): New.
	(compute_distance_vector): Renamed compute_subscript_distance.
	Deal with multivariate conflict functions.
	(initialize_data_dependence_relation): Initialize DDR_AFFINE_P,
	DDR_SIZE_VECT, DDR_DIST_VECT, and DDR_DIR_VECT.
	(non_affine_dependence_relation): New.
	(analyze_ziv_subscript, analyze_siv_subscript_cst_affine,
	analyze_siv_subscript, analyze_miv_subscript,
	analyze_overlapping_iterations, subscript_dependence_tester):
	Initialize and return last_conflicts function.
	(initialize_matrix_A, FLOOR, compute_overlap_steps_for_affine_univar,
	compute_overlap_steps_for_affine_1_2): New.
	(analyze_siv_subscript_affine_cst): Removed.
	(analyze_subscript_affine_affine): Disprove dependences based on the
	iteration domains.  Solve the univariate dependence case as before,
	but use lambda_matrix_right_hermite instead of tree_fold_bezout.
	Implement the multivariate case of 2 versus 1 variables.
	(build_classic_dist_vector, build_classic_dir_vector): Implement some
	unhandled cases.
	(find_data_references_in_loop): Compute and initialize
	loop->estimated_nb_iterations and loop->parallel_p.
	(analyze_all_data_dependences): Modify the debug dump order.
	* tree-data-ref.h (SUB_LAST_CONFLICT_IN_A, SUB_LAST_CONFLICT_IN_B,
	subscript->last_conflict_in_a, subscript->last_conflict_in_b): Removed.
	(SUB_LAST_CONFLICT, subscript->last_conflict,
	data_dependence_relation->affine_p, data_dependence_relation->size_vect,
	DDR_AFFINE_P, DDR_SIZE_VECT): New.
	(find_data_references_in_loop, initialize_data_dependence_relation,
	dump_subscript, dump_ddrs, dump_dist_dir_vectors): Declared here.

From-SVN: r88965
2004-10-13 03:48:03 +00:00
Zdenek Dvorak e6845c2382 tree-chrec.c (chrec_fold_plus_poly_poly, [...]): Use fold_convert or build_int_cst_type instead od fonvert.
* tree-chrec.c (chrec_fold_plus_poly_poly, chrec_fold_plus_1,
	chrec_fold_multiply): Use fold_convert or build_int_cst_type instead
	od fonvert.
	* tree-scalar-evolution.c (compute_overall_effect_of_inner_loop,
	add_to_evolution, set_nb_iterations_in_loop, follow_ssa_edge_in_rhs,
	follow_ssa_edge_in_rhs): Ditto.
	* tree-ssa-loop-ivopts.c (struct iv): Add base_object field.
	(dump_iv): Dump base_object.
	(dump_use, dump_cand): Use dump_iv.
	(determine_base_object): New function.
	(alloc_iv): Initialize base_object field.
	(record_use): Clear the ssa_name field of iv.
	(get_computation_cost_at): Do not use difference of addresses of
	two different objects.
	(may_eliminate_iv): Do not require the loop to have just single exit.
	* tree-ssa-loop-niter.c (zero_p): Do not check for overflows.
	(nonzero_p): New function.
	(inverse, number_of_iterations_cond, simplify_using_outer_evolutions,
	tree_simplify_using_condition, simplify_using_initial_conditions,
	loop_niter_by_eval, find_loop_niter_by_eval,
	estimate_numbers_of_iterations_loop, compare_trees,
	upper_bound_in_type, lower_bound_in_type,
	can_count_iv_in_wider_type_bound): Use buildN instead of build.  Use
	fold_convert or build_int_cst_type instead of convert.  Use (non)zero_p
	instead of integer_(non)zerop.

From-SVN: r88388
2004-10-01 09:06:06 +00:00
Ben Elliston 628f6a4e7c backport: basic-block.h: Include vec.h, errors.h.
2004-09-24  Ben Elliston  <bje@au.ibm.com>
	    Steven Bosscher  <stevenb@suse.de>
	    Andrew Pinski  <pinskia@physics.uc.edu>

	Merge from edge-vector-branch:
	* basic-block.h: Include vec.h, errors.h. Instantiate a VEC(edge).
	(struct edge_def): Remove pred_next, succ_next members.
	(struct basic_block_def): Remove pred, succ members.  Add preds
	and succs members of type VEC(edge).
	(FALLTHRU_EDGE): Redefine using EDGE_SUCC.
	(BRANCH_EDGE): Likewise.
	(EDGE_CRITICAL_P): Redefine using EDGE_COUNT.
	(EDGE_COUNT, EDGE_I, EDGE_PRED, EDGE_SUCC): New.
	(edge_iterator): New.
	(ei_start, ei_last, ei_end_p, ei_one_before_end_p): New.
	(ei_next, ei_prev, ei_edge, ei_safe_edge): Likewise.
	(FOR_EACH_EDGE): New.
	* bb-reorder.c (find_traces): Use FOR_EACH_EDGE and EDGE_* macros
	where applicable.
	(rotate_loop): Likewise.
	(find_traces_1_route): Likewise.
	(bb_to_key): Likewise.
	(connect_traces): Likewise.
	(copy_bb_p): Likewise.
	(find_rarely_executed_basic_blocks_and_crossing_edges): Likewise.
	(add_labels_and_missing_jumps): Likewise.
	(fix_up_fall_thru_edges): Likewise.
	(find_jump_block): Likewise.
	(fix_crossing_conditional_branches): Likewise.
	(fix_crossing_unconditional_branches): Likewise.
	(add_reg_crossing_jump_notes): Likewise.
	* bt-load.c (augment_live_range): Likewise.
	* cfg.c (clear_edges): Likewise.
	(unchecked_make_edge): Likewise.
	(cached_make_edge): Likewise.
	(make_single_succ_edge): Likewise.
	(remove_edge): Likewise.
	(redirect_edge_succ_nodup): Likewise.
	(check_bb_profile): Likewise.
	(dump_flow_info): Likewise.
	(alloc_aux_for_edges): Likewise.
	(clear_aux_for_edges): Likewise.
	(dump_cfg_bb_info): Likewise.
	* cfganal.c (forwarder_block_p): Likewise.
	(can_fallthru): Likewise.
	(could_fall_through): Likewise.
	(mark_dfs_back_edges): Likewise.
	(set_edge_can_fallthru_flag): Likewise.
	(find_unreachable_blocks): Likewise.
	(create_edge_list): Likewise.
	(verify_edge_list): Likewise.
	(add_noreturn_fake_exit_edges): Likewise.
	(connect_infinite_loops_to_exit): Likewise.
	(flow_reverse_top_sort_order_compute): Likewise.
	(flow_depth_first_order_compute): Likewise.
	(flow_preorder_transversal_compute): Likewise.
	(flow_dfs_compute_reverse_execute): Likewise.
	(dfs_enumerate_from): Likewise.
	(compute_dominance_frontiers_1): Likewise.
	* cfgbuild.c (make_edges): Likewise.
	(compute_outgoing_frequencies): Likewise.
	(find_many_sub_basic_blocks): Likewise.
	(find_sub_basic_blocks): Likewise.
	* cfgcleanup.c (try_simplify_condjump): Likewise.
	(thread_jump): Likewise.
	(try_forward_edges): Likewise.
	(merge_blocks_move): Likewise.
	(outgoing_edges_match): Likewise.
	(try_crossjump_to_edge): Likewise.
	(try_crossjump_bb): Likewise.
	(try_optimize_cfg): Likewise.
	(merge_seq_blocks): Likewise.
	* cfgexpand.c (expand_gimple_tailcall): Likewise.
	(expand_gimple_basic_block): Likewise.
	(construct_init_block): Likewise.
	(construct_exit_block): Likewise.
	* cfghooks.c (verify_flow_info): Likewise.
	(dump_bb): Likewise.
	(delete_basic_block): Likewise.
	(split_edge): Likewise.
	(merge_blocks): Likewise.
	(make_forwarder_block): Likewise.
	(tidy_fallthru_edges): Likewise.
	(can_duplicate_block_p): Likewise.
	(duplicate_block): Likewise.
	* cfglayout.c (fixup_reorder_chain): Likewise.
	(fixup_fallthru_exit_predecessor): Likewise.
	(can_copy_bbs_p): Likewise.
	(copy_bbs): Likewise.
	* cfgloop.c (flow_loops_cfg_dump): Likewise.
	(flow_loop_entry_edges_find): Likewise.
	(flow_loop_exit_edges_find): Likewise.
	(flow_loop_nodes_find): Likewise.
	(mark_single_exit_loops): Likewise.
	(flow_loop_pre_header_scan): Likewise.
	(flow_loop_pre_header_find): Likewise.
	(update_latch_info): Likewise.
	(canonicalize_loop_headers): Likewise.
	(flow_loops_find): Likewise.
	(get_loop_body_in_bfs_order): Likewise.
	(get_loop_exit_edges): Likewise.
	(num_loop_branches): Likewise.
	(verify_loop_structure): Likewise.
	(loop_latch_edge): Likewise.
	(loop_preheader_edge): Likewise.
	* cfgloopanal.c (mark_irreducible_loops): Likewise.
	(expected_loop_iterations): Likewise.
	* cfgloopmanip.c (remove_bbs): Likewise.
	(fix_bb_placement): Likewise.
	(fix_irreducible_loops): Likewise.
	(remove_path): Likewise.
	(scale_bbs_frequencies): Likewise.
	(loopify): Likewise.
	(unloop): Likewise.
	(fix_loop_placement): Likewise.
	(loop_delete_branch_edge): Likewise.
	(duplicate_loop_to_header_edge): Likewise.
	(mfb_keep_just): Likewise.
	(create_preheader): Likewise.
	(force_single_succ_latches): Likewise.
	(loop_split_edge_with): Likewise.
	(create_loop_notes): Likewise.
	* cfgrtl.c (rtl_split_block): Likewise.
	(rtl_merge_blocks): Likewise.
	(rtl_can_merge_blocks): Likewise.
	(try_redirect_by_replacing_jump): Likewise.
	(force_nonfallthru_and_redirect): Likewise.
	(rtl_tidy_fallthru_edge): Likewise.
	(commit_one_edge_insertion): Likewise.
	(commit_edge_insertions): Likewise.
	(commit_edge_insertions_watch_calls): Likewise.
	(rtl_verify_flow_info_1): Likewise.
	(rtl_verify_flow_info): Likewise.
	(purge_dead_edges): Likewise.
	(cfg_layout_redirect_edge_and_branch): Likewise.
	(cfg_layout_can_merge_blocks_p): Likewise.
	(rtl_flow_call_edges_add): Likewise.
	* cse.c (cse_cc_succs): Likewise.
	* df.c (hybrid_search): Likewise.
	* dominance.c (calc_dfs_tree_nonrec): Likewise.
	(calc_dfs_tree): Likewise.
	(calc_idoms): Likewise.
	(recount_dominator): Likewise.
	* domwalk.c (walk_dominator_tree): Likewise.
	* except.c (emit_to_new_bb_before): Likewise.
	(connect_post_landing_pads): Likewise.
	(sjlj_emit_function_enter): Likewise.
	(sjlj_emit_function_exit): Likewise.
	(finish_eh_generation): Likewise.
	* final.c (compute_alignments): Likewise.
	* flow.c (calculate_global_regs_live): Likewise.
	(initialize_uninitialized_subregs): Likewise.
	(init_propagate_block_info): Likewise.
	* function.c (thread_prologue_and_epilogue_insns): Likewise.
	* gcse.c (find_implicit_sets): Likewise.
	(bypass_block): Likewise.
	(bypass_conditional_jumps): Likewise.
	(compute_pre_data): Likewise.
	(insert_insn_end_bb): Likewise.
	(insert_store): Likewise.
	(remove_reachable_equiv_notes): Likewise.
	* global.c (global_conflicts): Likewise.
	(calculate_reg_pav): Likewise.
	* graph.c (print_rtl_graph_with_bb): Likewise.
	* ifcvt.c (mark_loop_exit_edges): Likewise.
	(merge_if_block): Likewise.
	(find_if_header): Likewise.
	(block_jumps_and_fallthru_p): Likewise.
	(find_if_block): Likewise.
	(find_cond_trap): Likewise.
	(block_has_only_trap): Likewise.
	(find_if_case1): Likewise.
	(find_if_case_2): Likewise.
	* lambda-code.c (lambda_loopnest_to_gcc_loopnest): Likewise.
	(perfect_nestify): Likewise.
	* lcm.c (compute_antinout_edge): Likewise.
	(compute_laterin): Likewise.
	(compute_available): Likewise.
	(compute_nearerout): Likewise.
	* loop-doloop.c (doloop_modify): Likewise.
	* loop-init.c (loop_optimizer_init): Likewise.
	* loop-invariant.c (find_exits): Likewise.
	* loop-iv.c (simplify_using_initial_values): Likewise.
	(check_simple_exit): Likewise.
	(find_simple_exit): Likewise.
	* loop-unroll.c (peel_loop_completely): Likewise.
	(unroll_loop_constant_iterations): Likewise.
	(unroll_loop_runtime_iterations): Likewise.
	* loop-unswitch.c (may_unswitch_on): Likewise.
	(unswitch_loop): Likewise.
	* modulo-sched.c (generate_prolog_epilog): Likewise.
	(sms_schedule): Likewise.
	* postreload-gcse.c (eliminate_partially_redundant_load):
	Likewise.
	* predict.c (can_predict_insn_p): Likewise.
	(set_even_probabilities): Likewise.
	(combine_predictions_for_bb): Likewise.
	(predict_loops): Likewise.
	(estimate_probability): Likewise.
	(tree_predict_by_opcode): Likewise.
	(tree_estimate_probability): Likewise.
	(last_basic_block_p): Likewise.
	(propagate_freq): Likewise.
	(estimate_loops_at_level): Likewise.
	(estimate_bb_frequencies): Likewise.
	* profile.c (instrument_edges): Likewise.
	(get_exec_counts): Likewise.
	(compute_branch_probabilities): Likewise.
	(branch_prob): Likewise.
	* ra-build.c (live_in): Likewise.
	* ra-rewrite.c (rewrite_program2): Likewise.
	* ra.c (reg_alloc): Likewise.
	* reg-stack.c (reg_to_stack): Likewise.
	(convert_regs_entry): Likewise.
	(compensate_edge): Likewise.
	(convert_regs_1): Likewise,
	(convert_regs_2): Likewise.
	(convert_regs): Likewise.
	* regrename.c (copyprop_hardreg_forward): Likewise.
	* reload1.c (fixup_abnormal_edges): Likewise.
	* sbitmap.c (sbitmap_intersection_of_succs): Likewise.
	(sbitmap_insersection_of_preds): Likewise.
	(sbitmap_union_of_succs): Likewise.
	(sbitmap_union_of_preds): Likewise.
	* sched-ebb.c (compute_jump_reg_dependencies): Likewise.
	(fix_basic_block_boundaries): Likewise.
	(sched_ebbs): Likewise.
	* sched-rgn.c (build_control_flow): Likewise.
	(find_rgns): Likewise.
	* tracer.c (find_best_successor): Likewise.
	(find_best_predecessor): Likewise.
	(tail_duplicate): Likewise.
	* tree-cfg.c (make_edges): Likewise.
	(make_ctrl_stmt_edges): Likewise.
	(make_goto_expr_edges): Likewise.
	(tree_can_merge_blocks_p): Likewise.
	(tree_merge_blocks): Likewise.
	(cfg_remove_useless_stmts_bb): Likewise.
	(remove_phi_nodes_and_edges_for_unreachable_block): Likewise.
	(tree_block_forwards_to): Likewise.
	(cleanup_control_expr_graph): Likewise.
	(find_taken_edge): Likewise.
	(dump_cfg_stats): Likewise.
	(tree_cfg2vcg): Likewise.
	(disband_implicit_edges): Likewise.
	(tree_find_edge_insert_loc): Likewise.
	(bsi_commit_edge_inserts): Likewise.
	(tree_split_edge): Likewise.
	(tree_verify_flow_info): Likewise.
	(tree_make_forwarder_block): Likewise.
	(tree_forwarder_block_p): Likewise.
	(thread_jumps): Likewise.
	(tree_try_redirect_by_replacing_jump): Likewise.
	(tree_split_block): Likewise.
	(add_phi_args_after_copy_bb): Likewise.
	(rewrite_to_new_ssa_names_bb): Likewise.
	(dump_function_to_file): Likewise.
	(print_pred_bbs): Likewise.
	(print_loop): Likewise.
	(tree_flow_call_edges_add): Likewise.
	(split_critical_edges): Likewise.
	(execute_warn_function_return): Likewise.
	(extract_true_false_edges_from_block): Likewise.
	* tree-if-conv.c (tree_if_conversion): Likewise.
	(if_convertable_bb_p): Likewise.
	(find_phi_replacement_condition): Likewise.
	(combine_blocks): Likewise.
	* tree-into-ssa.c (compute_global_livein): Likewise.
	(ssa_mark_phi_uses): Likewise.
	(ssa_rewrite_initialize_block): Likewise.
	(rewrite_add_phi_arguments): Likewise.
	(ssa_rewrite_phi_arguments): Likewise.
	(insert_phi_nodes_for): Likewise.
	(rewrite_into_ssa): Likewise.
	(rewrite_ssa_into_ssa): Likewise.
	* tree-mudflap.c (mf_build_check_statement_for): Likewise.
	* tree-outof-ssa.c (coalesce_abnormal_edges): Likewise.
	(rewrite_trees): Likewise.
	* tree-pretty-print.c (dump_bb_header): Likewise.
	(dump_implicit_edges): Likewise.
	* tree-sra.c (insert_edge_copies): Likewise.
	(find_obviously_necessary_stmts): Likewise.
	(remove_data_stmt): Likewise.
	* tree-ssa-dom.c (thread_across_edge): Likewise.
	(dom_opt_finalize_block): Likewise.
	(single_incoming_edge_ignoring_loop_edges): Likewise.
	(record_equivalences_from_incoming_edges): Likewise.
	(cprop_into_successor_phis): Likewise.
	* tree-ssa-live.c (live_worklist): Likewise.
	(calculate_live_on_entry): Likewise.
	(calculate_live_on_exit): Likewise.
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Likewise.
	(copy_loop_headers): Likewise.
	* tree-ssa-loop-im.c (loop_commit_inserts): Likewise.
	(fill_always_executed_in): Likewise.
	* tree-ssa-loop-ivcanon.c (create_canonical_iv): Likewise.
	* tree-ssa-loop-ivopts.c (find_interesting_uses): Likewise.
	(compute_phi_arg_on_exit): Likewise.
	* tree-ssa-loop-manip.c (add_exit_phis_edge): Likewise.
	(get_loops_exit): Likewise.
	(split_loop_exit_edge): Likewise.
	(ip_normal_pos): Likewise.
	* tree-ssa-loop-niter.c (simplify_using_initial_conditions):
	Likewise.
	* tree-ssa-phiopt.c (candidate_bb_for_phi_optimization): Likewise.
	(replace_phi_with_stmt): Likewise.
	(value_replacement): Likewise.
	* tree-ssa-pre.c (compute_antic_aux): Likewise.
	(insert_aux): Likewise.
	(init_pre): Likewise.
	* tree-ssa-propagate.c (simulate_stmt): Likewise.
	(simulate_block): Likewise.
	(ssa_prop_init): Likewise.
	* tree-ssa-threadupdate.c (thread_block): Likewise.
	(create_block_for_threading): Likewise.
	(remove_last_stmt_and_useless_edges): Likewise.
	* tree-ssa.c (verify_phi_args): Likewise.
	(verify_ssa): Likewise.
	* tree_tailcall.c (independent_of_stmt_p): Likewise.
	(find_tail_calls): Likewise.
	(eliminate_tail_call): Likewise.
	(tree_optimize_tail_calls_1): Likewise.
	* tree-vectorizer.c (vect_transform_loop): Likewise.
	* var-tracking.c (prologue_stack_adjust): Likewise.
	(vt_stack_adjustments): Likewise.
	(vt_find_locations): Likewise.
	* config/frv/frv.c (frv_ifcvt_modify_tests): Likewise.
	* config/i386/i386.c (ix86_pad_returns): Likewise.
	* config/ia64/ia64.c (ia64_expand_prologue): Likewise.
	* config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise.

Co-Authored-By: Andrew Pinski <pinskia@physics.uc.edu>
Co-Authored-By: Steven Bosscher <stevenb@suse.de>

From-SVN: r88222
2004-09-28 17:59:54 +10:00
Zdenek Dvorak 2f4675b482 fold-const.c (fold): Fold difference of addresses.
* fold-const.c (fold): Fold difference of addresses.
	(ptr_difference_const): Moved from tree-ssa-loop-ivopts, based on
	get_inner_reference.
	* tree-ssa-loop-ivopts.c (peel_address): Removed.
	(ptr_difference_const): Moved to fold-const.c.
	(split_address_cost): Use get_inner_reference instead of peel_address.
	(ptr_difference_cost): Change type of diff to HOST_WIDE_INT.
	* tree.h (ptr_difference_const): Export.

	* tree-ssa-loop-ivopts.c (dump_iv, dump_use, dump_cand): Add induction
	variable type to the dump.  Fix indentation.
	(idx_find_step): Handle nonconstant array_ref_element_size and
	array_ref_low_bound.
	(idx_record_use): Handle array_ref_element_size and
	array_ref_low_bound.
	(find_interesting_uses_stmt): Handle memory = nontrivial_expression
	statements correctly.
	(get_computation_at, iv_value): Do not unshare expressions here.
	(rewrite_use_outer): Unshare the expression before it is emitted
	to code.
	* tree-ssa-loop-niter.c (unsigned_type_for, signed_type_for):
	Moved to tree.c.
	* tree.c (unsigned_type_for, signed_type_for): Moved from
	tree-ssa-loop-niter.c.  Use langhooks.
	* tree.h (signed_type_for): Export.

From-SVN: r87601
2004-09-16 14:58:01 +00:00
Kazu Hirata 2a7e31df70 c-common.c, [...]: Fix comment typos.
* c-common.c, cfgexpand.c, cgraphunit.c, defaults.h,
	et-forest.c, expr.c, gimplify.c, global.c, gthr-lynx.h,
	hard-reg-set.h, modulo-sched.c, optabs.c, postreload-gcse.c,
	tree-data-ref.c, tree-flow.h, tree-if-conv.c, tree-inline.c,
	tree-sra.c, tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c,
	tree-ssa-loop-niter.c, tree-ssa-operands.c,
	tree-ssa-operands.h, tree-ssa-propagate.c,
	tree-ssa-propagate.h, tree-ssa-threadupdate.c, value-prof.c,
	vec.c, vec.h: Fix comment typos.  Follow spelling conventions.

From-SVN: r87104
2004-09-05 15:24:15 +00:00
Zdenek Dvorak 8b11a64cd9 tree-ssa-loop-ivopts.c: New file.
* tree-ssa-loop-ivopts.c: New file.
	* Makefile.in (tree-ssa-loop-ivopts.c): Add.
	* cfgloop.h (target_avail_regs, target_res_regs, target_small_cost,
	target_pres_cost, target_spill_cost): Declare.
	* cfgloopanal.c (avail_regs, res_regs, small_cost, pres_cost,
	spill_cost): Renamed to ...
	(target_avail_regs, target_res_regs, target_small_cost,
	target_pres_cost, target_spill_cost): ... and exported.
	(init_set_costs, global_cost_for_size): Work with renamed variables.
	* common.opt (flag_ivopts): New flag.
	* expr.c (expand_expr_real_1): Handle SSA_NAME case.  Handle
	REF_ORIGINAL.
	* gimplify.c (struct gimplify_ctx): Add into_ssa field.
	(internal_get_tmp_var, gimplify_modify_expr, gimplify_expr): Support
	generating SSA form.
	(force_gimple_operand): New function.
	* timevar.def (TV_TREE_LOOP_IVOPTS): New timevar.
	* tree-cfg.c (stmt_bsi): New function.
	* params.def (PARAM_IV_CONSIDER_ALL_CANDIDATES_BOUND,
	PARAM_IV_MAX_CONSIDERED_USES): New.
	* tree-flow.h (stmt_bsi, tree_ssa_iv_optimize, split_loop_exit_edge,
	bsi_insert_on_edge_immediate_loop. standard_iv_increment_position,
	ip_end_pos, ip_normal_pos, force_gimple_operand): Declare.
	* tree-gimple.c (is_gimple_formal_tmp_var): Accept ssa names.
	* tree-nested.c (build_addr): Export.
	* tree-optimize.c (init_tree_optimization_passes): Add
	pass_iv_optimize.
	* tree-pass.h (pass_iv_optimize): Declare.
	* tree-ssa-loop-im.c (for_each_index): Handle REALPART_EXPR and
	IMAGPART_EXPR.
	* tree-ssa-loop-manip.c (create_iv): Force the base to be acceptable
	as a phi node argument.
	(split_loop_exit_edge, bsi_insert_on_edge_immediate_loop,
	ip_end_pos, ip_normal_pos, standard_iv_increment_position): New
	functions.
	* tree-ssa-loop-niter.c (zero_p, unsigned_type_for): Export.
	* tree-ssa-loop.c (tree_ssa_loop_ivopts, gate_tree_ssa_loop_ivopts,
	pass_iv_optimize): New pass.
	* tree-ssa-operands.c (get_indirect_ref_operands): Handle REF_ORIGINAL.
	* tree-ssanames.c (release_ssa_name): Allow calling with var = NULL.
	* tree.c (build_int_cst_type, cst_and_fits_in_hwi): New functions.
	* tree.h (REF_ORIGINAL): New macro.
	(build_int_cst_type, unsigned_type_for, zero_p,
	cst_and_fits_in_hwi, build_addr): Declare.
	* doc/invoke.texi (-fivopts): Document.
	(PARAM_IV_CONSIDER_ALL_CANDIDATES_BOUND,
	PARAM_IV_MAX_CONSIDERED_USES): Document.
	* doc/passes.texi: Document induction variable optimizations pass.

	* gcc.dg/tree-ssa/loop-2.c: New test.
	* gcc.dg/tree-ssa/loop-3.c: New test.
	* gcc.dg/tree-ssa/loop-4.c: New test.
	* gcc.dg/tree-ssa/loop-5.c: New test.

From-SVN: r87100
2004-09-05 09:25:37 +00:00
Nathan Sidwell 7d60be94d6 tree.h (build_int_cst): New, sign extended constant.
* tree.h  (build_int_cst): New, sign extended constant.
	(build_int_cstu): New, zero extended constant.
	(build_int_cst_wide): Renamed from build_int_cst.
	* tree.c (build_int_cst, build_int_cstu): New.
	(build_int_cst_wide): Renamed from build_int_cst.
	(make_vector_type, build_common_tree_nodes,
	build_common_tree_nodes_2): Adjust build_int_cst calls.
	* builtins.c (expand_builtin_prefetch, expand_builtin_strstr,
	expand_builtin_strpbrk, expand_builtin_fputs,
	build_string_literal, expand_builtin_printf,
	expand_builtin_sprintf, fold_builtin_classify_type,
	fold_builtin_lround, fold_builtin_bitop, fold_builtin_isascii,
	fold_builtin_toascii, fold_builtin_isdigit,
	simplify_builtin_strstr, simplify_builtin_strpbrk,
	fold_builtin_fputs, simplify_builtin_sprintf): Likewise.
	* c-common.c (start_fname_decls, fix_string_type, shorten_compare,
	DEF_ATTR_INT): Likewise.
	* c-decl.c (complete_array_type, check_bitfield_type_and_width):
	Likewise.
	* c-lex.c (interpret_integer, lex_charconst): Likewise.
	* c-parse.in (primary) <TYPES_COMPATIBLE_P> Likewise.
	* c-pretty-print.c (pp_c_integer_constant): Likewise.
	* c-typeck.c (really_start_incremental_init, push_init_level,
	set_nonincremental_init_from_string): Likewise.
	* calls.c (load_register_parameters): Likewise.
	convert.c (convert_to_pointer): Likewise.
	coverage.c (coverage_counter_alloc, tree_coverage_counter_ref,
	build_fn_info_type, build_fn_info_value, build_ctr_info_value,
	build_gcov_info): Likewise.
	* except.c (init_eh, assign_filter_values): Likewise.
	* expmed.c (store_fixed_bit_field, extract_bit_field,
	extract_fixed_bit_field, extract_split_bit_field, expand_shift,
	expand_mult_const, expand_mult_highpart_adjust, extract_high_half,
	expand_sdiv_pow2, expand_divmod, make_tree): Likewise.
	* expr.c (convert_move, emit_group_load, emit_group_store,
	expand_assignment, store_constructor, store_field,
	expand_expr_real_1, reduce_to_bit_field_precision): Likewise.
	fold-const.c (force_fit_type, int_const_binop, fold_convert_const,
	invert_truthvalue, optimize_bit_field_compare,
	decode_field_reference, all_ones_mask_p, constant_boolean_node,
	fold_div_compare, fold, fold_read_from_constant_string,
	fold_negate_const, fold_abs_const, fold_not_const, round_up,
	round_down): Likewise.
	* function.c (assign_parm_setup_block): Likewise.
	* stmt.c (shift_return_value, expand_case, estimate_case_costs):
	Likewise.
	* stor-layout.c (layout_type, initialize_sizetypes,
	set_min_and_max_values_for_integral_type): Likewise.
	* tree-chrec.c (chrec_fold_multiply_poly_poly,
	reset_evolution_in_loop): Likewise.
	* tree-chrec.h (build_polynomial_chrec): Likewise.
	* tree-complex.c (build_replicated_const): Likewise.
	* tree-eh.c (honor_protect_cleanup_actions,
	lower_try_finally_onedest, lower_try_finally_copy,
	lower_try_finally_switch): Likewise.
	* tree-mudflap.c (mf_build_string, mx_register_decls,
	mudflap_register_call, mudflap_enqueue_constant): Likewise.
	* tree-nested.c (get_trampoline_type, get_nl_goto_field): Likewise.
	* tree-pretty-print.c (dump_generic_node): Likewise.
	* tree-ssa-ccp.c (widen_bitfield, maybe_fold_offset_to_array_ref):
	Likewise.
	* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Likewise.
	* tree-ssa-loop-niter.c (number_of_iterations_cond,
	loop_niter_by_eval, upper_bound_in_type, lower_bound_in_type):
	Likewise.
	* tree-ssa-loop-ivcanon.c (create_canonical_iv,
	canonicalize_loop_induction_variables): Likewise.
	* tree-vectorizer.c (vect_create_index_for_array_ref,
	vect_transform_loop_bound, vect_compute_data_ref_alignment):
	Likewise.

	* config/alpha/alpha.c (alpha_initialize_trampoline, alpha_va_start,
	alpha_gimplify_va_arg_1): Likewise.
	* config/arm/arm.c (arm_get_cookie_size): Likewise.
	* config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Likewise.
	* config/i386/i386.c (ix86_va_start, ix86_gimplify_va_arg): Likewise.
	* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
	* config/mips/mips.c (mips_build_builtin_va_list, mips_va_start,
	mips_gimplify_va_arg_expr): Likewise.
	* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
	* config/rs6000/rs6000.c (rs6000_va_start, rs6000_gimplify_va_arg,
	add_compiler_branch_island): Likewise.
	* config/s390/s390.c (s390_va_start): Likewise.
	* config/sh/sh.c (sh_va_start): Likewise.
	* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_start):
	Likewise.
	* config/xtensa/xtensa.c (xtensa_va_start,
	xtensa_gimplify_va_arg_expr): Likewise.

	* objc/objc-act.c (build_objc_string_object,
	build_objc_symtab_template, init_def_list, init_objc_symtab,
	init_module_descriptor, generate_static_references,
	build_selector_translation_table, get_proto_encoding,
	build_typed_selector_reference, build_selector_reference,
	build_next_objc_exception_stuff,
	build_method_prototype_list_template, generate_descriptor_table,
	generate_protocols, build_protocol_initializer,
	build_ivar_list_template, build_method_list_template,
	build_ivar_list_initializer, generate_ivars_list,
	generate_dispatch_table, generate_protocol_list,
	build_category_initializer, build_shared_structure_initializer,
	generate_shared_structures, handle_impent,
	generate_objc_image_info): Likewise.

2004-04-25  Paolo Bonzini  <bonzini@gnu.org>

	* cfglayout.c (duplicate_insn_chain): Remove references to
	NOTE_INSN_LOOP_VTOP and NOTE_INSN_LOOP_CONT.
	* cfgloop.h (struct loop): Remove fields vtop, cont and cont_dominator.
	* cfgrtl.c (rtl_delete_block): Remove handling of NOTE_INSN_LOOP_CONT.
	* final.c (final_scan_insn): Remove references to NOTE_INSN_LOOP_VTOP
	and NOTE_INSN_LOOP_CONT.
	* insn-notes.def (NOTE_INSN_LOOP_VTOP, NOTE_INSN_LOOP_CONT): Remove.
	* jump.c (squeeze_notes): Remove references to NOTE_INSN_LOOP_VTOP
	and NOTE_INSN_LOOP_CONT.
	* loop.c (scan_loops, find_and_verify_loops, for_each_insn_in_loop,
	check_dbra_loop, loop_dump_aux): Remove references to removed notes
	and fields.
	* reorg.c (mostly_true_jump): Do not rely on NOTE_INSN_LOOP_VTOPs.
	* unroll.c (unroll_loop, copy_loop_body, loop_iterations): Remove
	references to removed notes and fields.
	(subtract_reg_term, ujump_to_loop_cont): Remove.

From-SVN: r86544
2004-08-25 09:52:54 +00:00
Zdenek Dvorak b3393f1f4d re PR tree-optimization/17016 (ICE with struct passed as reference)
PR tree-optimization/17016
	* tree-ssa-loop-niter.c (number_of_iterations_cond,
	number_of_iterations_exit): Use POINTER_TYPE_P instead
	of testing for POINTER_TYPE.

From-SVN: r86517
2004-08-24 20:50:42 +00:00
Zdenek Dvorak 82b85a85c8 tree-ssa-loop-ivcanon.c: New file.
* tree-ssa-loop-ivcanon.c: New file.
	* tree-ssa-loop-manip.c (create_iv): New function.
	* Makefile.in (tree-ssa-loop-ivcanon.o): Add.
	(tree-ssa-loop.o, tree-ssa-loop-manip.o): Add SCEV_H dependency.
	* cfgloop.c (mark_single_exit_loops): New function.
	(verify_loop_structure): Verify single-exit loops.
	* cfgloop.h (struct loop): Add single_exit field.
	(LOOPS_HAVE_MARKED_SINGLE_EXITS): New constant.
	(mark_single_exit_loops): Declare.
	(tree_num_loop_insns): Declare.
	* cfgloopmanip.c (update_single_exits_after_duplication): New function.
	(duplicate_loop_to_header_edge): Use it.
	* common.opt (fivcanon): New flag.
	* timevar.def (TV_TREE_LOOP_IVCANON, TV_COMPLETE_UNROLL): New timevars.
	* tree-cfg.c (tree_find_edge_insert_loc): Return newly created block.
	(bsi_commit_edge_inserts_1): Pass null to tree_find_edge_insert_loc.
	(bsi_insert_on_edge_immediate): New function.
	* tree-flow.h (bsi_insert_on_edge_immediate,
	canonicalize_induction_variables, tree_unroll_loops_completely,
	create_iv): Declare.
	* tree-optimize.c (init_tree_optimization_passes): Add
	pass_iv_canon and pass_complete_unroll.
	* tree-pass.h (pass_iv_canon, pass_complete_unroll): Declare.
	* tree-scalar-evolution.c (get_loop_exit_condition,
	get_exit_conditions_rec, number_of_iterations_in_loop,
	scev_initialize): Use single_exit information.
	* tree-ssa-loop-niter.c (number_of_iterations_cond): Record
	missing assumptions.
	(loop_niter_by_eval):  Return number of iterations as unsigned
	int.
	* tree-ssa-loop.c (tree_ssa_loop_init): Mark single exit loops.
	(tree_ssa_loop_ivcanon, gate_tree_ssa_loop_ivcanon, pass_iv_canon,
	tree_complete_unroll, gate_tree_complete_unroll, pass_complete_unroll):
	New passes.
	(tree_ssa_loop_done): Call free_numbers_of_iterations_estimates.
	* tree-ssanames.c (make_ssa_name): Allow creating ssa name before
	the defining statement is ready.
	* tree-vectorizer.c (vect_create_iv_simple): Removed.
	(vect_create_index_for_array_ref, vect_transform_loop_bound):
	Use create_iv.
	(vect_transform_loop_bound): Use single_exit information.
	(vect_analyze_loop_form): Cleanup bogus tests.
	(vectorize_loops): Do not call flow_loop_scan.
	* tree.h (may_negate_without_overflow_p): Declare.
	* fold-const.c (may_negate_without_overflow_p): Split out from ...
	(negate_expr_p): ... this function.
	(tree_expr_nonzero_p): Handle overflowed constants correctly.
	* doc/invoke.texi (-fivcanon): Document.
	* doc/passes.texi: Document canonical induction variable creation.

	* gcc.dg/tree-ssa/loop-1.c: New test.

From-SVN: r86516
2004-08-24 20:48:23 +00:00
Nathan Sidwell 4a90aeeb51 tree.h (build_int_cst): New.
.:	* tree.h (build_int_cst): New.
	(build_int_2): Remove.
	* tree.c (build_int_2): Remove.
	(build_int_cst): New.
	(make_vector_type, build_common_tree_nodes,
	build_common_tree_nodes_2): Use build_int_cst.
	* builtins.c (expand_builtin_prefetch, expand_builtin_strstr,
	expand_builtin_strpbrk, expand_builtin_fputs,
	build_string_literal, expand_builtin_printf,
	expand_builtin_sprintf, fold_builtin_lround, fold_builtin_bitop,
	fold_builtin_bitop, fold_builtin_isascii, fold_builtin_toascii,
	fold_builtin_isdigit, simplify_builtin_strstr,
	simplify_builtin_strpbrk, fold_builtin_fputs,
	simplify_builtin_sprintf): Use build_int_cst.
	* c-common.c (start_fname_decls, fix_string_type,
	c_common_nodes_and_builtins, c_init_attributes,
	shorten_compare): Likewise.
	* c-decl.c (complete_array_type,
	check_bitfield_type_and_width): Likewise.
	* c-lex.c (interpret_integer, lex_charconst): Likewise.
	* c-parse.in (primary): <TYPES_COMPATIBLE_P> Likewise.
	* c-pretty-print.c (pp_c_integer_constant): Likewise.
	* c-typeck.c (really_start_incremental_init, push_init_level,
	set_nonincremental_init_from_string): Likewise.
	* calls.c (load_register_parameters): Likewise.
	* convert.c (convert_to_pointer): Likewise.
	* coverage.c (coverage_counter_alloc, tree_coverage_counter_ref,
	build_fn_info_type, build_ctr_info_value, build_gcov_info):
	Likewise.
	* except.c (init_eh, assign_filter_values, assign_filter_values):
	Likewise.
	* expmed.c (store_fixed_bit_field, extract_bit_field,
	extract_fixed_bit_field, extract_split_bit_field, expand_shift,
	expand_mult_const, expand_mult_highpart_adjust, extract_high_half,
	expand_sdiv_pow2, expand_divmod, make_tree): Likewise.
	* expr.c (convert_move, emit_group_load, emit_group_store,
	expand_assignment, store_constructor, store_field,
	expand_expr_real_1, reduce_to_bit_field_precision): Likewise.
	* fold-const.c (force_fit_type, int_const_binop, fold_convert_const,
	invert_truthvalue, optimize_bit_field_compare,
	decode_field_reference, all_ones_mask_p, constant_boolean_node,
	fold_div_compare, fold, fold_read_from_constant_string,
	fold_negate_const, fold_abs_const, fold_not_const): Likewise.
	* function.c (assign_parm_setup_block): Likewise.
	* stmt.c (shift_return_value, expand_end_case_type,
	estimate_case_costs): Likewise.
	* stor-layout.c (layout_type, initialize_sizetypes,
	set_min_and_max_values_for_integral_type): Likewise.
	* tree-chrec.c (chrec_fold_multiply_poly_poly,
	reset_evolution_in_loop): Likewise.
	* tree-chrec.h (build_polynomial_chrec): Likewise.
	* tree-complex.c (build_replicated_const): Likewise.
	* tree-eh.c (honor_protect_cleanup_actions,
	lower_try_finally_onedest, lower_try_finally_copy,
	lower_try_finally_switch): Likewise.
	* tree-mudflap.c (mf_build_string, mx_register_decls,
	mudflap_register_call, mudflap_enqueue_constant): Likewise.
	* tree-nested.c (get_trampoline_type, get_nl_goto_field): Likewise.
	* tree-pretty-print.c (dump_generic_node): Likewise.
	* tree-ssa-ccp.c (widen_bitfield, maybe_fold_offset_to_array_ref):
	Likewise.
	* tree-ssa-dom.c (simplify_rhs_and_lookup_avail_expr): Likewise.
	* tree-ssa-loop-niter.c (number_of_iterations_cond,
	loop_niter_by_eval, upper_bound_in_type, lower_bound_in_type):
	Likewise.

	* config/alpha/alpha.c (alpha_initialize_trampoline,
	alpha_va_start, alpha_gimplify_va_arg_1): Use build_int_cst.
	* config/arm/arm.c (arm_get_cookie_size): Likewise.
	* config/c4x/c4x.c (c4x_gimplify_va_arg_expr): Likewise.
	* config/i386/i386.c (ix86_va_start, ix86_gimplify_va_arg): Likewise.
	* config/i860/i860.c (i860_va_start): Likewise.
	* config/ia64/ia64.c (ia64_gimplify_va_arg): Likewise.
	* config/mips/mips.c (mips_build_builtin_va_list, mips_va_start,
	mips_gimplify_va_arg_expr): Likewise.
	* config/pa/pa.c (hppa_gimplify_va_arg_expr): Likewise.
	* config/rs6000/rs6000.c (rs6000_va_start, rs6000_gimplify_va_arg,
	add_compiler_branch_island): Likewise.
	* config/s390/s390.c (s390_va_start): Likewise.
	* config/sh/sh.c (sh_va_start): Likewise.
	* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_start):
	Likewise.
	* config/xtensa/xtensa.c (xtensa_va_start,
	xtensa_gimplify_va_arg_expr): Likewise.

	* objc/objc-act.c (build_objc_string_object,
	build_objc_symtab_template, init_def_list, init_objc_symtab,
	init_module_descriptor, generate_static_references,
	build_selector_translation_table, get_proto_encoding,
	build_typed_selector_reference, build_selector_reference,
	build_next_objc_exception_stuff,
	build_method_prototype_list_template, generate_descriptor_table,
	generate_protocols, build_protocol_initializer,
	build_ivar_list_template, build_method_list_template,
	build_ivar_list_initializer, generate_ivars_list,
	generate_dispatch_table, generate_protocol_list,
	build_category_initializer, build_shared_structure_initializer,
	generate_shared_structures, handle_impent,
	generate_objc_image_info): Use build_int_cst.
ada:
	* cuintp.c (UI_To_gnu): Use build_int_cst..
	* trans.c (Exception_Handler_to_gnu_sjlj, gnat_to_gnu): Likewise.
	* utils.c (init_gigi_decls): Likewise.
	* utils2.c (build_call_raise): Likewise.
cp:
	* call.c (convert_class_to_reference,
	build_user_type_conversion_1, convert_like_real,
	build_java_interface_fn_ref, build_special_member_call): Use
	build_int_cst.
	* class.c (build_vtbl_initializer): Likewise.
	* cp-gimplify.c (cp_gimplify_expr): Likewise.
	* cvt.c (cp_convert_to_pointer): Likewise.
	* decl.c (cxx_init_decl_processing, complete_array_type): Likewise.
	* decl2.c (start_static_initialization_or_destruction,
	generate_ctor_or_dtor_function): Likewise.
	* except.c (build_throw): Likewise.
	* lex.c (cxx_init): Likewise.
	* mangle.c (write_integer_cst): Likewise.
	* rtti.c (build_headof, get_tinfo_decl_dynamic,
	build_dynamic_cast_1, ptr_initializer, ptm_initializer,
	get_pseudo_ti_init): Likewise.
	* search.c (get_dynamic_cast_base_type): Likewise.
	* tree.c (build_shared_int_cst): Likewise.
fortran:
	* trans-array.c (gfc_trans_array_constructor_value): Use
	build_int_cst.
	* trans-const.c (gfc_build_string_const,
	gfc_init_constants, gfc_conv_mpz_to_tree,
	gfc_conv_constant_to_tree): Likewise.
	* trans-decl.c (gfc_get_symbol_decl): Likewise.
	* trans-intrinsic.c (gfc_conv_intrinsic_ibits,
	gfc_conv_intrinsic_len, prepare_arg_info): Likewise.
	* trans-io.c (add_case, set_error_locus, build_dt,
	transfer_expr): Likewise.
	* trans-stmt.c (gfc_trans_label_assign, gfc_trans_pause,
	gfc_trans_stop, gfc_trans_character_select): Likewise.
	* trans-types.c (gfc_init_types, gfc_get_dtype): Likewise.
	* trans.c (gfc_trans_runtime_check): Likewise.
java:
	* boehm.c (get_boehm_type_descriptor): Use build_int_cst.
	* class.c (build_utf8_ref, build_static_field_ref,
	make_field_value, make_method_value, get_dispatch_table,
	make_class_data, emit_symbol_table, emit_catch_table): Likewise.
	* constants.c (get_tag_node,  build_ref_from_constant_pool,
	build_constants_constructor): Likewise.
	* decl.c (java_init_decl_processing): Likewise.
	* expr.c (build_java_array_length_access, build_newarray,
	expand_java_multianewarray, expand_java_pushc, expand_iinc,
	build_java_binop, build_field_ref, expand_java_add_case,
	expand_java_call, build_known_method_ref, build_invokevirtual,
	build_invokeinterface, build_jni_stub): Likewise.
	* java-gimplify.c (java_gimplify_new_array_init): Likewise.
	* jcf-parse.c (get_constant): Likewise.
	* lex.c (do_java_lex): Likewise.
	* parse.y (patch_binop, patch_unaryop, patch_cast,
	build_null_of_type, patch_newarray): Likewise.
	* resource.c (compile_resource_data): Likewise.
	* typeck.c (build_prim_array_type): Likewise.

From-SVN: r86022
2004-08-15 15:45:33 +00:00
Zdenek Dvorak e9eb809dec tree-scalar-evolution.c: New file.
* tree-scalar-evolution.c: New file.
	* tree-scalar-evolution.h: New file.
	* tree-ssa-loop-niter.c: New file.
	* Makefile.in (SCEV_H): New.
	(tree-scalar-evolution.o, tree-ssa-loop-niter.o): Add new files.
	* cfgloop.h (struct loop): Add bounds field.
	* tree-flow.h (struct tree_niter_desc): New type.
	(number_of_iterations_cond, number_of_iterations_exit,
	loop_niter_by_eval, find_loop_niter_by_eval,
	estimate_numbers_of_iterations, can_count_iv_in_wider_type,
	free_numbers_of_iterations_estimates): Declare.
	* tree.h (lower_bound_in_type, upper_bound_in_type): Declare.
	* params.def (PARAM_MAX_ITERATIONS_TO_TRACK): New parameter.
	* doc/invoke.texi (max-iterations-to-track): Document.

From-SVN: r84340
2004-07-09 03:19:14 +00:00