diff options
author | Xinliang David Li <davidxl@google.com> | 2010-11-03 22:25:53 +0000 |
---|---|---|
committer | Xinliang David Li <davidxl@gcc.gnu.org> | 2010-11-03 22:25:53 +0000 |
commit | 2fa692c0dfc8385a3b2535ecd9b6b8ef2d0055e5 (patch) | |
tree | 8b5f37ff39681da2eb648312b37db5360bde9238 /gcc/tree-ssa-loop-ivopts.c | |
parent | 9451da7425d50f767912a2126e1681317dec0869 (diff) | |
download | gcc-2fa692c0dfc8385a3b2535ecd9b6b8ef2d0055e5.zip gcc-2fa692c0dfc8385a3b2535ecd9b6b8ef2d0055e5.tar.gz gcc-2fa692c0dfc8385a3b2535ecd9b6b8ef2d0055e5.tar.bz2 |
Fix PR/46200
From-SVN: r166280
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 88fc015..ab2e67a 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4027,6 +4027,8 @@ get_computation_cost_at (struct ivopts_data *data, STRIP_NOPS (cbase); ctype = TREE_TYPE (cbase); + stmt_is_after_inc = stmt_after_increment (data->current_loop, cand, at); + /* use = ubase + ratio * (var - cbase). If either cbase is a constant or ratio == 1, it is better to handle this like @@ -4045,8 +4047,24 @@ get_computation_cost_at (struct ivopts_data *data, } else if (ratio == 1) { + tree real_cbase = cbase; + + /* Check to see if any adjustment is needed. */ + if (cstepi == 0 && stmt_is_after_inc) + { + aff_tree real_cbase_aff; + aff_tree cstep_aff; + + tree_to_aff_combination (cbase, TREE_TYPE (real_cbase), + &real_cbase_aff); + tree_to_aff_combination (cstep, TREE_TYPE (cstep), &cstep_aff); + + aff_combination_add (&real_cbase_aff, &cstep_aff); + real_cbase = aff_combination_to_tree (&real_cbase_aff); + } + cost = difference_cost (data, - ubase, cbase, + ubase, real_cbase, &symbol_present, &var_present, &offset, depends_on); cost.cost /= avg_loop_niter (data->current_loop); @@ -4088,7 +4106,6 @@ get_computation_cost_at (struct ivopts_data *data, /* If we are after the increment, the value of the candidate is higher by one iteration. */ - stmt_is_after_inc = stmt_after_increment (data->current_loop, cand, at); if (stmt_is_after_inc) offset -= ratio * cstepi; |