Hi, This is the major part of this patch series. It rewrites cost computation of ivopts using tree affine. Apart from description given by cover message: A) New computation cost model. Currently, there are big amount code trying to understand tree expression and estimate its computation cost. The model is designed long ago for generic tree expressions. In order to process generic expression (even address expression of array/memory references), it has code for too many corner cases. The problem is it's somehow impossible to handle all complicated expressions, even with complicated logic in functions like get_computation_cost_at, difference_cost, ptr_difference_cost, get_address_cost and so on... The second problem is it's hard to keep cost model consistent among special cases. As special cases being added from time to time, the model is no long unified any more. There are cases that right cost results in bad code, or vice versa, wrong cost results in good code. Finally, it's difficult to add code for new cases. This patch introduces a new cost computation model by using tree affine. Tree exprs are lowered to aff_tree which is simple arithmetic operation usually. Code handling special cases is no longer necessary, which brings us quite simplicity. It is also easier to compute consistent costs among different expressions using tree affine, which gives us a unified cost model. This patch also fixes issue that cost computation for address type iv_use is inconsistent with how it is re-rewritten in the end. It greatly simplified cost computation. Is it OK? Thanks, bin 2017-04-11 Bin Cheng * tree-ssa-loop-ivopts.c (get_loop_invariant_expr): Simplify. (adjust_setup_cost): New parameter supporting round up adjustment. (struct address_cost_data): Delete. (force_expr_to_var_cost): Don't bound cost with spill_cost. (split_address_cost, ptr_difference_cost): Delete. (difference_cost, compare_aff_trees, record_inv_expr): Delete. (struct ainc_cost_data): New struct. (get_address_cost_ainc): New function. (get_address_cost, get_computation_cost): Reimplement. (determine_group_iv_cost_address): Record inv_expr for all uses of a group. (determine_group_iv_cost_cond): Call get_loop_invariant_expr. (iv_ca_has_deps): Reimplemented to ... (iv_ca_more_deps): ... this. Check if NEW_CP introduces more deps than OLD_CP. (iv_ca_extend): Call iv_ca_more_deps.