aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-08-07 05:58:29 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1999-08-07 05:58:29 +0000
commitef797f788d3e044850e4a8138c450bd9b492daf0 (patch)
tree45230121cf14163b5eaf2bbd7a918f476dbc0aae
parent4c4a739fb9065f0566f7bd9800fae304ca3f07d2 (diff)
* reg-stack.c (change_stack) Fixed problem with negative array index.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-2_95-branch@28571 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/reg-stack.c53
2 files changed, 32 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b0d298ca8a8..23508826945 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+1999-08-6 Herman A.J. ten Brugge <Haj.Ten.Brugge@net.HCC.nl>
+
+ * reg-stack.c (change_stack) Fixed problem with negative array index.
+
Fri Aug 6 20:41:08 1999 Jeffrey A Law (law@cygnus.com)
Mon Jul 19 15:09:29 1999 David Edelsohn <edelsohn@gnu.org>
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 8a27b9563b6..dd4a87e697c 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -2640,43 +2640,46 @@ change_stack (insn, old, new, when)
if (old->top != new->top)
abort ();
- /* Loop here emitting swaps until the stack is correct. The
- worst case number of swaps emitted is N + 2, where N is the
+ /* If the stack is not empty (new->top != -1), loop here emitting
+ swaps until the stack is correct.
+
+ The worst case number of swaps emitted is N + 2, where N is the
depth of the stack. In some cases, the reg at the top of
stack may be correct, but swapped anyway in order to fix
other regs. But since we never swap any other reg away from
its correct slot, this algorithm will converge. */
- do
- {
- /* Swap the reg at top of stack into the position it is
- supposed to be in, until the correct top of stack appears. */
+ if (new->top != -1)
+ do
+ {
+ /* Swap the reg at top of stack into the position it is
+ supposed to be in, until the correct top of stack appears. */
- while (old->reg[old->top] != new->reg[new->top])
- {
- for (reg = new->top; reg >= 0; reg--)
- if (new->reg[reg] == old->reg[old->top])
- break;
+ while (old->reg[old->top] != new->reg[new->top])
+ {
+ for (reg = new->top; reg >= 0; reg--)
+ if (new->reg[reg] == old->reg[old->top])
+ break;
- if (reg == -1)
- abort ();
+ if (reg == -1)
+ abort ();
- emit_swap_insn (insn, old,
- FP_MODE_REG (old->reg[reg], DFmode));
- }
+ emit_swap_insn (insn, old,
+ FP_MODE_REG (old->reg[reg], DFmode));
+ }
- /* See if any regs remain incorrect. If so, bring an
+ /* See if any regs remain incorrect. If so, bring an
incorrect reg to the top of stack, and let the while loop
above fix it. */
- for (reg = new->top; reg >= 0; reg--)
- if (new->reg[reg] != old->reg[reg])
- {
- emit_swap_insn (insn, old,
- FP_MODE_REG (old->reg[reg], DFmode));
- break;
- }
- } while (reg >= 0);
+ for (reg = new->top; reg >= 0; reg--)
+ if (new->reg[reg] != old->reg[reg])
+ {
+ emit_swap_insn (insn, old,
+ FP_MODE_REG (old->reg[reg], DFmode));
+ break;
+ }
+ } while (reg >= 0);
/* At this point there must be no differences. */