From a53c50249f684027ef6ca3957b0811e4ecb233e7 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 19 May 2011 08:49:28 +0000 Subject: [PATCH] re PR middle-end/45098 (Missed induction variable optimization) 2011-05-19 Tom de Vries PR target/45098 * tree-ssa-loop-ivopts.c (determine_iv_cost): Prevent cost_base.cost == 0. From-SVN: r173893 --- gcc/ChangeLog | 6 ++++++ gcc/tree-ssa-loop-ivopts.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c695f9b7998..a3ce4ef982d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-05-19 Tom de Vries + + PR target/45098 + * tree-ssa-loop-ivopts.c (determine_iv_cost): Prevent + cost_base.cost == 0. + 2011-05-18 H.J. Lu PR target/49002 diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 501dbbf4526..1580aec006a 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4690,6 +4690,11 @@ determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand) base = cand->iv->base; cost_base = force_var_cost (data, base, NULL); + /* It will be exceptional that the iv register happens to be initialized with + the proper value at no cost. In general, there will at least be a regcopy + or a const set. */ + if (cost_base.cost == 0) + cost_base.cost = COSTS_N_INSNS (1); cost_step = add_cost (TYPE_MODE (TREE_TYPE (base)), data->speed); cost = cost_step + adjust_setup_cost (data, cost_base.cost); -- 2.30.2