aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorCorey Minyard <minyard@acm.org>2001-11-27 18:30:40 +0000
committerRichard Henderson <rth@gcc.gnu.org>2001-11-27 10:30:40 -0800
commitec3fba5614d0ac97acf5a60164a4fdc0ad21791f (patch)
treec922a76f1382f72691ef5b5d6b95f6ea94186174 /gcc
parentb856c15d7e97280853a83042ccb3ba29c79e7e9f (diff)
downloadgcc-ec3fba5614d0ac97acf5a60164a4fdc0ad21791f.zip
gcc-ec3fba5614d0ac97acf5a60164a4fdc0ad21791f.tar.gz
gcc-ec3fba5614d0ac97acf5a60164a4fdc0ad21791f.tar.bz2
unroll.c (loop_iterations): Detect one situation in which we overestimate the number of iterations.
* unroll.c (loop_iterations): Detect one situation in which we overestimate the number of iterations. Co-Authored-By: Richard Henderson <rth@redhat.com> From-SVN: r47386
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/unroll.c35
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b118193..00e6134 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2001-11-17 Corey Minyard <minyard@acm.org>
+ Richard Henderson <rth@redhat.com>
+
+ * unroll.c (loop_iterations): Detect one situation in which we
+ overestimate the number of iterations.
+
2001-11-27 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* gcc.c (set_input): Export.
diff --git a/gcc/unroll.c b/gcc/unroll.c
index 4b7dd97..35ce939 100644
--- a/gcc/unroll.c
+++ b/gcc/unroll.c
@@ -3706,6 +3706,41 @@ loop_iterations (loop)
if (initial_value == 0)
return 0;
+ /* Some code transformations can result in code akin to
+
+ tmp = i + 1;
+ ...
+ goto scan_start;
+ top:
+ tmp = tmp + 1;
+ scan_start:
+ i = tmp;
+ if (i < n) goto top;
+
+ We'll have already detected this form of loop in scan_loop,
+ and set loop->top and loop->scan_start appropriately.
+
+ In this situation, we skip the increment the first time through
+ the loop, which results in an incorrect estimate of the number
+ of iterations. Adjust the initial value to compensate. */
+
+ if (loop->scan_start && loop->cont
+ && INSN_LUID (loop->scan_start) < INSN_LUID (loop->cont)
+ && INSN_LUID (bl->biv->insn) < INSN_LUID (loop->scan_start))
+ {
+ if (loop_dump_stream)
+ fprintf (loop_dump_stream,
+ "Loop iterations: Basic induction var skips initial incr.\n");
+ if (GET_CODE (increment) != CONST_INT)
+ {
+ if (loop_dump_stream)
+ fprintf (loop_dump_stream,
+ "Loop iterations: Can't adjust with non-constant incr.\n");
+ return 0;
+ }
+ initial_value = plus_constant (initial_value, -INTVAL (increment));
+ }
+
unsigned_p = 0;
off_by_one = 0;
switch (comparison_code)