summaryrefslogtreecommitdiffstats
path: root/gcc/unroll.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-11-27 18:30:40 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-11-27 18:30:40 +0000
commitffaa56d8468e7779e93217dfae0521a508f9afc6 (patch)
treec922a76f1382f72691ef5b5d6b95f6ea94186174 /gcc/unroll.c
parent32d661fc0faff0dce34cf68892529fef5905141f (diff)
downloadppe42-gcc-ffaa56d8468e7779e93217dfae0521a508f9afc6.tar.gz
ppe42-gcc-ffaa56d8468e7779e93217dfae0521a508f9afc6.zip
* unroll.c (loop_iterations): Detect one situation in which we
overestimate the number of iterations. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47386 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/unroll.c')
-rw-r--r--gcc/unroll.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/unroll.c b/gcc/unroll.c
index 4b7dd974925..35ce939f012 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)
OpenPOWER on IntegriCloud