aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-06-17 21:31:32 +0000
committerRichard Stallman <rms@gnu.org>1993-06-17 21:31:32 +0000
commit6511b4f8b16644cf439fdc75c38badb2e020373b (patch)
tree8b326b7f99e23ec20da18596e58aa585d5b2ff45 /gcc
parent5b0f630beeaa6692f021f32bdbe2a341ab4f4a8a (diff)
downloadgcc-6511b4f8b16644cf439fdc75c38badb2e020373b.zip
gcc-6511b4f8b16644cf439fdc75c38badb2e020373b.tar.gz
gcc-6511b4f8b16644cf439fdc75c38badb2e020373b.tar.bz2
(calculate_giv_inc): Add new variables increment_total and tries...
(calculate_giv_inc): Add new variables increment_total and tries, and new label retry, to handle case where increment is two add instructions. From-SVN: r4689
Diffstat (limited to 'gcc')
-rw-r--r--gcc/unroll.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/gcc/unroll.c b/gcc/unroll.c
index 71c26a0..fc8a3f6 100644
--- a/gcc/unroll.c
+++ b/gcc/unroll.c
@@ -1,5 +1,5 @@
/* Try to unroll loops, and split induction variables.
- Copyright (C) 1992 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1993 Free Software Foundation, Inc.
Contributed by James E. Wilson, Cygnus Support/UC Berkeley.
This file is part of GNU CC.
@@ -1318,7 +1318,10 @@ calculate_giv_inc (pattern, src_insn, regno)
int regno;
{
rtx increment;
+ rtx increment_total = 0;
+ int tries = 0;
+ retry:
/* Verify that we have an increment insn here. First check for a plus
as the set source. */
if (GET_CODE (SET_SRC (pattern)) != PLUS)
@@ -1341,7 +1344,8 @@ calculate_giv_inc (pattern, src_insn, regno)
{
/* SR sometimes puts the constant in a register, especially if it is
too big to be an add immed operand. */
- increment = SET_SRC (PATTERN (PREV_INSN (src_insn)));
+ src_insn = PREV_INSN (src_insn);
+ increment = SET_SRC (PATTERN (src_insn));
/* SR may have used LO_SUM to compute the constant if it is too large
for a load immed operand. In this case, the constant is in operand
@@ -1357,12 +1361,36 @@ calculate_giv_inc (pattern, src_insn, regno)
delete_insn (get_last_insn ());
}
- /* Check that the source register is the same as the dest register. */
+ if (increment_total)
+ increment_total = GEN_INT (INTVAL (increment_total) + INTVAL (increment));
+ else
+ increment_total = increment;
+
+ /* Check that the source register is the same as the register we expected
+ to see as the source. If not, something is seriously wrong. */
if (GET_CODE (XEXP (SET_SRC (pattern), 0)) != REG
|| REGNO (XEXP (SET_SRC (pattern), 0)) != regno)
- abort ();
+ {
+ /* Some machines (e.g. the romp), may emit two add instructions for
+ certain constants, so lets try looking for another add immediately
+ before this one if we have only seen one add insn so far. */
+
+ if (tries == 0)
+ {
+ tries++;
+
+ src_insn = PREV_INSN (src_insn);
+ pattern = PATTERN (src_insn);
+
+ delete_insn (get_last_insn ());
+
+ goto retry;
+ }
+
+ abort ();
+ }
- return increment;
+ return increment_total;
}
/* Copy REG_NOTES, except for insn references, because not all insn_map