aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2004-12-25 23:53:54 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2004-12-25 22:53:54 +0000
commiteec5fec983fd8738d842a5d916086b29aeb650bf (patch)
treedd158a2937b61524aac9d3dd24821202ba8b51d8
parent6b262ee81e0c4a4d4e2c1afc0b9f6fdb980f7365 (diff)
downloadgcc-eec5fec983fd8738d842a5d916086b29aeb650bf.zip
gcc-eec5fec983fd8738d842a5d916086b29aeb650bf.tar.gz
gcc-eec5fec983fd8738d842a5d916086b29aeb650bf.tar.bz2
re PR rtl-optimization/19078 (Poor quality code after loop unrolling.)
PR rtl-optimization/19078 * tree-ssa-loop-ivopts.c (determine_use_iv_cost_generic, determine_use_iv_cost_outer): Fix computing of cost for the original bivs. (dump_use): Handle case related_cands == NULL. From-SVN: r92608
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/tree-ssa-loop-ivopts.c34
2 files changed, 38 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 76b79a4..db26b3a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-25 Zdenek Dvorak <dvorakz@suse.cz>
+
+ PR rtl-optimization/19078
+ * tree-ssa-loop-ivopts.c (determine_use_iv_cost_generic,
+ determine_use_iv_cost_outer): Fix computing of cost for the original
+ bivs.
+ (dump_use): Handle case related_cands == NULL.
+
2004-12-25 Marek Michalkiewicz <marekm@amelek.gda.pl>
PR target/19059
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index d1a1bdd..7303412 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -444,8 +444,11 @@ dump_use (FILE *file, struct iv_use *use)
dump_iv (file, use->iv);
- fprintf (file, " related candidates ");
- dump_bitmap (file, use->related_cands);
+ if (use->related_cands)
+ {
+ fprintf (file, " related candidates ");
+ dump_bitmap (file, use->related_cands);
+ }
}
/* Dumps information about the uses to FILE. */
@@ -3116,8 +3119,20 @@ determine_use_iv_cost_generic (struct ivopts_data *data,
struct iv_use *use, struct iv_cand *cand)
{
bitmap depends_on;
- unsigned cost = get_computation_cost (data, use, cand, false, &depends_on);
+ unsigned cost;
+
+ /* The simple case first -- if we need to express value of the preserved
+ original biv, the cost is 0. This also prevents us from counting the
+ cost of increment twice -- once at this use and once in the cost of
+ the candidate. */
+ if (cand->pos == IP_ORIGINAL
+ && cand->incremented_at == use->stmt)
+ {
+ set_use_iv_cost (data, use, cand, 0, NULL);
+ return true;
+ }
+ cost = get_computation_cost (data, use, cand, false, &depends_on);
set_use_iv_cost (data, use, cand, cost, depends_on);
return cost != INFTY;
@@ -3311,7 +3326,18 @@ determine_use_iv_cost_outer (struct ivopts_data *data,
edge exit;
tree value;
struct loop *loop = data->current_loop;
-
+
+ /* The simple case first -- if we need to express value of the preserved
+ original biv, the cost is 0. This also prevents us from counting the
+ cost of increment twice -- once at this use and once in the cost of
+ the candidate. */
+ if (cand->pos == IP_ORIGINAL
+ && cand->incremented_at == use->stmt)
+ {
+ set_use_iv_cost (data, use, cand, 0, NULL);
+ return true;
+ }
+
if (!cand->iv)
{
if (!may_replace_final_value (loop, use, &value))