diff options
author | Zdenek Dvorak <dvorakz@suse.cz> | 2005-01-19 23:50:04 +0100 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2005-01-19 22:50:04 +0000 |
commit | 4366cf6d6fd7f35682cdcdbe5fabcbf1ac42b2ed (patch) | |
tree | 29e5422130765c2da580006f646d90ee08cd9e2d | |
parent | 75aa3f658cb028f17b0d80fcbf322b3da0e615cb (diff) | |
download | gcc-4366cf6d6fd7f35682cdcdbe5fabcbf1ac42b2ed.zip gcc-4366cf6d6fd7f35682cdcdbe5fabcbf1ac42b2ed.tar.gz gcc-4366cf6d6fd7f35682cdcdbe5fabcbf1ac42b2ed.tar.bz2 |
re PR tree-optimization/19038 (tree-ssa causing loops to have more than one BB)
PR tree-optimization/19038
* tree-ssa-loop-ivopts.c (allow_ip_end_pos_p): New function.
(add_candidate): Add ivs with increment in latch only if
allow_ip_end_pos_p is true.
(determine_iv_cost): Use empty_block_p.
From-SVN: r93925
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 39 |
2 files changed, 35 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e255439..5141fc0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-01-19 Zdenek Dvorak <dvorakz@suse.cz> + + PR tree-optimization/19038 + * tree-ssa-loop-ivopts.c (allow_ip_end_pos_p): New function. + (add_candidate): Add ivs with increment in latch only if + allow_ip_end_pos_p is true. + (determine_iv_cost): Use empty_block_p. + 2005-01-19 Daniel Berlin <dberlin@dberlin.org> * cfganal.c (compute_dominance_frontiers_1): Replace with new algorithm diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index d35ae51..3288080 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1779,6 +1779,27 @@ add_candidate_1 (struct ivopts_data *data, return cand; } +/* Returns true if incrementing the induction variable at the end of the LOOP + is allowed. + + The purpose is to avoid splitting latch edge with a biv increment, thus + creating a jump, possibly confusing other optimization passes and leaving + less freedom to scheduler. So we allow IP_END_POS only if IP_NORMAL_POS + is not available (so we do not have a better alternative), or if the latch + edge is already nonempty. */ + +static bool +allow_ip_end_pos_p (struct loop *loop) +{ + if (!ip_normal_pos (loop)) + return true; + + if (!empty_block_p (ip_end_pos (loop))) + return true; + + return false; +} + /* Adds a candidate BASE + STEP * i. Important field is set to IMPORTANT and position to POS. If USE is not NULL, the candidate is set as related to it. The candidate computation is scheduled on all available positions. */ @@ -1789,7 +1810,8 @@ add_candidate (struct ivopts_data *data, { if (ip_normal_pos (data->current_loop)) add_candidate_1 (data, base, step, important, IP_NORMAL, use, NULL_TREE); - if (ip_end_pos (data->current_loop)) + if (ip_end_pos (data->current_loop) + && allow_ip_end_pos_p (data->current_loop)) add_candidate_1 (data, base, step, important, IP_END, use, NULL_TREE); } @@ -3518,8 +3540,7 @@ static void determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand) { unsigned cost_base, cost_step; - tree base, last; - basic_block bb; + tree base; if (!cand->iv) { @@ -3543,15 +3564,9 @@ determine_iv_cost (struct ivopts_data *data, struct iv_cand *cand) /* Prefer not to insert statements into latch unless there are some already (so that we do not create unnecessary jumps). */ - if (cand->pos == IP_END) - { - bb = ip_end_pos (data->current_loop); - last = last_stmt (bb); - - if (!last - || TREE_CODE (last) == LABEL_EXPR) - cand->cost++; - } + if (cand->pos == IP_END + && empty_block_p (ip_end_pos (data->current_loop))) + cand->cost++; } /* Determines costs of computation of the candidates. */ |