From e0db140205f73e6fecf8dee1c1dd35d41e653d7b Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Tue, 3 May 2016 08:38:18 +0000 Subject: [PATCH] tree-ssa-loop-ivopts.c (get_computation_cost_at): Don't clobber cbase. * tree-ssa-loop-ivopts.c (get_computation_cost_at): Don't clobber cbase. From-SVN: r235805 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-loop-ivopts.c | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3910c62b5ab..d5895cacf54 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-05-03 Bin Cheng + + * tree-ssa-loop-ivopts.c (get_computation_cost_at): Don't clobber + cbase. + 2016-05-03 Oleg Endo * config/sh/sh.md (udivsi3, divsi3, mulsi3): Simplify. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 9314363b533..e6d35a4af7a 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4814,17 +4814,19 @@ get_computation_cost_at (struct ivopts_data *data, (ratio, mem_mode, TYPE_ADDR_SPACE (TREE_TYPE (utype)))) { + tree real_cbase = cbase; + if (cstepi == 0 && stmt_is_after_inc) { if (POINTER_TYPE_P (ctype)) - cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep); + real_cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep); else - cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep); + real_cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep); } - cbase - = fold_build2 (MULT_EXPR, ctype, cbase, build_int_cst (ctype, ratio)); + real_cbase = fold_build2 (MULT_EXPR, ctype, real_cbase, + build_int_cst (ctype, ratio)); cost = difference_cost (data, - ubase, cbase, + ubase, real_cbase, &symbol_present, &var_present, &offset, depends_on); cost.cost /= avg_loop_niter (data->current_loop); -- 2.30.2