OSDN Git Service

* misc.c (gnat_types_compatible_p, LANG_HOOKS_TYPES_COMPATIBLE_P):
[pf3gnuchains/gcc-fork.git] / gcc / reg-stack.c
index fc13759..11dd849 100644 (file)
                asm ("foo" : "=t" (a) : "f" (b));
 
       This asm says that input B is not popped by the asm, and that
-      the asm pushes a result onto the reg-stack, ie, the stack is one
+      the asm pushes a result onto the reg-stack, i.e., the stack is one
       deeper after the asm than it was before.  But, it is possible that
       reload will think that it can use the same reg for both the input and
       the output, if input B dies in this insn.
@@ -265,7 +265,6 @@ static int convert_regs_2 (FILE *, basic_block);
 static int convert_regs (FILE *);
 static void print_stack (FILE *, stack);
 static rtx next_flags_user (rtx);
-static void record_label_references (rtx, rtx);
 static bool compensate_edge (edge, FILE *);
 \f
 /* Return nonzero if any stack register is mentioned somewhere within PAT.  */
@@ -442,7 +441,9 @@ reg_to_stack (FILE *file)
   FOR_EACH_BB_REVERSE (bb)
     {
       edge e;
-      for (e = bb->pred; e; e = e->pred_next)
+      edge_iterator ei;
+
+      FOR_EACH_EDGE (e, ei, bb->preds)
        if (!(e->flags & EDGE_DFS_BACK)
            && e->src != ENTRY_BLOCK_PTR)
          BLOCK_INFO (bb)->predecessors++;
@@ -489,59 +490,7 @@ reg_to_stack (FILE *file)
   free_aux_for_blocks ();
   return true;
 }
-\f
-/* Check PAT, which is in INSN, for LABEL_REFs.  Add INSN to the
-   label's chain of references, and note which insn contains each
-   reference.  */
-
-static void
-record_label_references (rtx insn, rtx pat)
-{
-  enum rtx_code code = GET_CODE (pat);
-  int i;
-  const char *fmt;
-
-  if (code == LABEL_REF)
-    {
-      rtx label = XEXP (pat, 0);
-      rtx ref;
-
-      if (!LABEL_P (label))
-       abort ();
-
-      /* If this is an undefined label, LABEL_REFS (label) contains
-         garbage.  */
-      if (INSN_UID (label) == 0)
-       return;
 
-      /* Don't make a duplicate in the code_label's chain.  */
-
-      for (ref = LABEL_REFS (label);
-          ref && ref != label;
-          ref = LABEL_NEXTREF (ref))
-       if (CONTAINING_INSN (ref) == insn)
-         return;
-
-      CONTAINING_INSN (pat) = insn;
-      LABEL_NEXTREF (pat) = LABEL_REFS (label);
-      LABEL_REFS (label) = pat;
-
-      return;
-    }
-
-  fmt = GET_RTX_FORMAT (code);
-  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
-    {
-      if (fmt[i] == 'e')
-       record_label_references (insn, XEXP (pat, i));
-      if (fmt[i] == 'E')
-       {
-         int j;
-         for (j = 0; j < XVECLEN (pat, i); j++)
-           record_label_references (insn, XVECEXP (pat, i, j));
-       }
-    }
-}
 \f
 /* Return a pointer to the REG expression within PAT.  If PAT is not a
    REG, possible enclosed by a conversion rtx, return the inner part of
@@ -758,7 +707,7 @@ check_asm_stack_operands (rtx insn)
          if (operands_match_p (recog_data.operand[j], recog_data.operand[i]))
            {
              error_for_asm (insn,
-                            "output operand %d must use `&' constraint", j);
+                            "output operand %d must use %<&%> constraint", j);
              malformed_asm = 1;
            }
       }
@@ -782,21 +731,21 @@ check_asm_stack_operands (rtx insn)
 static int
 get_asm_operand_n_inputs (rtx body)
 {
-  if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
-    return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (body));
-
-  else if (GET_CODE (body) == ASM_OPERANDS)
-    return ASM_OPERANDS_INPUT_LENGTH (body);
-
-  else if (GET_CODE (body) == PARALLEL
-          && GET_CODE (XVECEXP (body, 0, 0)) == SET)
-    return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (XVECEXP (body, 0, 0)));
-
-  else if (GET_CODE (body) == PARALLEL
-          && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
-    return ASM_OPERANDS_INPUT_LENGTH (XVECEXP (body, 0, 0));
-
-  abort ();
+  switch (GET_CODE (body))
+    {
+    case SET:
+      gcc_assert (GET_CODE (SET_SRC (body)) == ASM_OPERANDS);
+      return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (body));
+      
+    case ASM_OPERANDS:
+      return ASM_OPERANDS_INPUT_LENGTH (body);
+      
+    case PARALLEL:
+      return get_asm_operand_n_inputs (XVECEXP (body, 0, 0));
+      
+    default:
+      gcc_unreachable ();
+    }
 }
 
 /* If current function returns its result in an fp stack register,
@@ -838,16 +787,12 @@ stack_result (tree decl)
 static void
 replace_reg (rtx *reg, int regno)
 {
-  if (regno < FIRST_STACK_REG || regno > LAST_STACK_REG
-      || ! STACK_REG_P (*reg))
-    abort ();
+  gcc_assert (regno >= FIRST_STACK_REG);
+  gcc_assert (regno <= LAST_STACK_REG);
+  gcc_assert (STACK_REG_P (*reg));
 
-  switch (GET_MODE_CLASS (GET_MODE (*reg)))
-    {
-    default: abort ();
-    case MODE_FLOAT:
-    case MODE_COMPLEX_FLOAT:;
-    }
+  gcc_assert (GET_MODE_CLASS (GET_MODE (*reg)) == MODE_FLOAT
+             || GET_MODE_CLASS (GET_MODE (*reg)) == MODE_COMPLEX_FLOAT);
 
   *reg = FP_MODE_REG (regno, GET_MODE (*reg));
 }
@@ -871,7 +816,7 @@ remove_regno_note (rtx insn, enum reg_note note, unsigned int regno)
     else
       note_link = &XEXP (this, 1);
 
-  abort ();
+  gcc_unreachable ();
 }
 
 /* Find the hard register number of virtual register REG in REGSTACK.
@@ -883,8 +828,7 @@ get_hard_regnum (stack regstack, rtx reg)
 {
   int i;
 
-  if (! STACK_REG_P (reg))
-    abort ();
+  gcc_assert (STACK_REG_P (reg));
 
   for (i = regstack->top; i >= 0; i--)
     if (regstack->reg[i] == REGNO (reg))
@@ -918,15 +862,13 @@ emit_pop_insn (rtx insn, stack regstack, rtx reg, enum emit_where where)
        pop_insn = emit_pop_insn (insn, regstack, reg1, where);
       if (get_hard_regnum (regstack, reg2) >= 0)
        pop_insn = emit_pop_insn (insn, regstack, reg2, where);
-      if (!pop_insn)
-       abort ();
+      gcc_assert (pop_insn);
       return pop_insn;
     }
 
   hard_regno = get_hard_regnum (regstack, reg);
 
-  if (hard_regno < FIRST_STACK_REG)
-    abort ();
+  gcc_assert (hard_regno >= FIRST_STACK_REG);
 
   pop_rtx = gen_rtx_SET (VOIDmode, FP_MODE_REG (hard_regno, DFmode),
                         FP_MODE_REG (FIRST_STACK_REG, DFmode));
@@ -966,8 +908,7 @@ emit_swap_insn (rtx insn, stack regstack, rtx reg)
 
   hard_regno = get_hard_regnum (regstack, reg);
 
-  if (hard_regno < FIRST_STACK_REG)
-    abort ();
+  gcc_assert (hard_regno >= FIRST_STACK_REG);
   if (hard_regno == FIRST_STACK_REG)
     return;
 
@@ -1055,8 +996,7 @@ swap_to_top (rtx insn, stack regstack, rtx src1, rtx src2)
 
   /* Place operand 1 at the top of stack.  */
   regno = get_hard_regnum (&temp_stack, src1);
-  if (regno < 0)
-    abort ();
+  gcc_assert (regno >= 0);
   if (regno != FIRST_STACK_REG)
     {
       k = temp_stack.top - (regno - FIRST_STACK_REG);
@@ -1069,8 +1009,7 @@ swap_to_top (rtx insn, stack regstack, rtx src1, rtx src2)
 
   /* Place operand 2 next on the stack.  */
   regno = get_hard_regnum (&temp_stack, src2);
-  if (regno < 0)
-    abort ();
+  gcc_assert (regno >= 0);
   if (regno != FIRST_STACK_REG + 1)
     {
       k = temp_stack.top - (regno - FIRST_STACK_REG);
@@ -1110,16 +1049,15 @@ move_for_stack_reg (rtx insn, stack regstack, rtx pat)
          int i;
 
          /* If this is a no-op move, there must not be a REG_DEAD note.  */
-         if (REGNO (src) == REGNO (dest))
-           abort ();
+         gcc_assert (REGNO (src) != REGNO (dest));
 
          for (i = regstack->top; i >= 0; i--)
            if (regstack->reg[i] == REGNO (src))
              break;
 
          /* The source must be live, and the dest must be dead.  */
-         if (i < 0 || get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
-           abort ();
+         gcc_assert (i >= 0);
+         gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG);
 
          /* It is possible that the dest is unused after this insn.
             If so, just pop the src.  */
@@ -1156,8 +1094,7 @@ move_for_stack_reg (rtx insn, stack regstack, rtx pat)
        }
 
       /* The destination ought to be dead.  */
-      if (get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
-       abort ();
+      gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG);
 
       replace_reg (psrc, get_hard_regnum (regstack, src));
 
@@ -1201,26 +1138,24 @@ move_for_stack_reg (rtx insn, stack regstack, rtx pat)
 
       replace_reg (psrc, FIRST_STACK_REG);
     }
-  else if (STACK_REG_P (dest))
+  else
     {
+      gcc_assert (STACK_REG_P (dest));
+
       /* Load from MEM, or possibly integer REG or constant, into the
         stack regs.  The actual target is always the top of the
         stack. The stack mapping is changed to reflect that DEST is
         now at top of stack.  */
 
       /* The destination ought to be dead.  */
-      if (get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
-       abort ();
+      gcc_assert (get_hard_regnum (regstack, dest) < FIRST_STACK_REG);
 
-      if (regstack->top >= REG_STACK_SIZE)
-       abort ();
+      gcc_assert (regstack->top < REG_STACK_SIZE);
 
       regstack->reg[++regstack->top] = REGNO (dest);
       SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
       replace_reg (pdest, FIRST_STACK_REG);
     }
-  else
-    abort ();
 
   return control_flow_insn_deleted;
 }
@@ -1456,8 +1391,8 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
          return control_flow_insn_deleted;
        }
       /* ??? Uninitialized USE should not happen.  */
-      else if (get_hard_regnum (regstack, *src) == -1)
-       abort ();
+      else
+       gcc_assert (get_hard_regnum (regstack, *src) != -1);
       break;
 
     case CLOBBER:
@@ -1483,8 +1418,7 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                else
                  {
                    note = find_reg_note (insn, REG_UNUSED, *dest);
-                   if (!note)
-                     abort ();
+                   gcc_assert (note);
                  }
                remove_note (insn, note);
                replace_reg (dest, FIRST_STACK_REG + 1);
@@ -1560,8 +1494,7 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
 
          case REG:
            /* This is a `tstM2' case.  */
-           if (*dest != cc0_rtx)
-             abort ();
+           gcc_assert (*dest == cc0_rtx);
            src1 = src;
 
            /* Fall through.  */
@@ -1636,8 +1569,8 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
 
                src1_hard_regnum = get_hard_regnum (regstack, *src1);
                src2_hard_regnum = get_hard_regnum (regstack, *src2);
-               if (src1_hard_regnum == -1 || src2_hard_regnum == -1)
-                 abort ();
+               gcc_assert (src1_hard_regnum != -1);
+               gcc_assert (src2_hard_regnum != -1);
 
                if (src1_hard_regnum != FIRST_STACK_REG
                    && src2_hard_regnum != FIRST_STACK_REG)
@@ -1743,8 +1676,7 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                /* Input should never die, it is
                   replaced with output.  */
                src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
-               if (src1_note)
-                 abort();
+               gcc_assert (!src1_note);
 
                if (STACK_REG_P (*dest))
                  replace_reg (dest, FIRST_STACK_REG);
@@ -1800,8 +1732,8 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
 
                /* Inputs should never die, they are
                   replaced with outputs.  */
-               if ((src1_note) || (src2_note))
-                 abort();
+               gcc_assert (!src1_note);
+               gcc_assert (!src2_note);
 
                swap_to_top (insn, regstack, *src1, *src2);
 
@@ -1831,8 +1763,8 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
 
                /* Inputs should never die, they are
                   replaced with outputs.  */
-               if ((src1_note) || (src2_note))
-                 abort();
+               gcc_assert (!src1_note);
+               gcc_assert (!src2_note);
 
                swap_to_top (insn, regstack, *src1, *src2);
 
@@ -1861,8 +1793,7 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                /* Input should never die, it is
                   replaced with output.  */
                src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
-               if (src1_note)
-                 abort();
+               gcc_assert (!src1_note);
 
                /* Push the result back onto stack. Empty stack slot
                   will be filled in second part of insn.  */
@@ -1888,8 +1819,7 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                /* Input should never die, it is
                   replaced with output.  */
                src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
-               if (src1_note)
-                 abort();
+               gcc_assert (!src1_note);
 
                /* Push the result back onto stack. Fill empty slot from
                   first part of insn and fix top of stack pointer.  */
@@ -1909,9 +1839,8 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                   The combination matches the PPRO fcomi instruction.  */
 
                pat_src = XVECEXP (pat_src, 0, 0);
-               if (GET_CODE (pat_src) != UNSPEC
-                   || XINT (pat_src, 1) != UNSPEC_FNSTSW)
-                 abort ();
+               gcc_assert (GET_CODE (pat_src) == UNSPEC);
+               gcc_assert (XINT (pat_src, 1) == UNSPEC_FNSTSW);
                /* Fall through.  */
 
              case UNSPEC_FNSTSW:
@@ -1920,14 +1849,13 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                   up before now.  */
 
                pat_src = XVECEXP (pat_src, 0, 0);
-               if (GET_CODE (pat_src) != COMPARE)
-                 abort ();
+               gcc_assert (GET_CODE (pat_src) == COMPARE);
 
                compare_for_stack_reg (insn, regstack, pat_src);
                break;
 
              default:
-               abort ();
+               gcc_unreachable ();
              }
            break;
 
@@ -1994,17 +1922,13 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
                    int regno = REGNO (XEXP (src_note[i], 0));
 
                    /* If the register that dies is not at the top of
-                      stack, then move the top of stack to the dead reg */
-                   if (regno != regstack->reg[regstack->top])
-                     {
-                       remove_regno_note (insn, REG_DEAD, regno);
-                       emit_pop_insn (insn, regstack, XEXP (src_note[i], 0),
-                                      EMIT_AFTER);
-                     }
-                   else
-                     /* Top of stack never dies, as it is the
-                        destination.  */
-                     abort ();
+                      stack, then move the top of stack to the dead reg.
+                      Top of stack should never die, as it is the
+                      destination.  */
+                   gcc_assert (regno != regstack->reg[regstack->top]);
+                   remove_regno_note (insn, REG_DEAD, regno);
+                   emit_pop_insn (insn, regstack, XEXP (src_note[i], 0),
+                                   EMIT_AFTER);
                  }
            }
 
@@ -2017,7 +1941,7 @@ subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
            break;
 
          default:
-           abort ();
+           gcc_unreachable ();
          }
        break;
       }
@@ -2074,8 +1998,7 @@ subst_asm_stack_regs (rtx insn, stack regstack)
   n_inputs = get_asm_operand_n_inputs (body);
   n_outputs = recog_data.n_operands - n_inputs;
 
-  if (alt < 0)
-    abort ();
+  gcc_assert (alt >= 0);
 
   /* Strip SUBREGs here to make the following code simpler.  */
   for (i = 0; i < recog_data.n_operands; i++)
@@ -2168,8 +2091,7 @@ subst_asm_stack_regs (rtx insn, stack regstack)
 
        int regno = get_hard_regnum (&temp_stack, recog_data.operand[i]);
 
-       if (regno < 0)
-         abort ();
+       gcc_assert (regno >= 0);
 
        if ((unsigned int) regno != REGNO (recog_data.operand[i]))
          {
@@ -2202,8 +2124,7 @@ subst_asm_stack_regs (rtx insn, stack regstack)
       {
        int regnum = get_hard_regnum (regstack, recog_data.operand[i]);
 
-       if (regnum < 0)
-         abort ();
+       gcc_assert (regnum >= 0);
 
        replace_reg (recog_data.operand_loc[i], regnum);
       }
@@ -2213,8 +2134,7 @@ subst_asm_stack_regs (rtx insn, stack regstack)
       {
        int regnum = get_hard_regnum (regstack, note_reg[i]);
 
-       if (regnum < 0)
-         abort ();
+       gcc_assert (regnum >= 0);
 
        replace_reg (note_loc[i], regnum);
       }
@@ -2228,7 +2148,7 @@ subst_asm_stack_regs (rtx insn, stack regstack)
       if (regnum >= 0)
        {
          /* Sigh - clobbers always have QImode.  But replace_reg knows
-            that these regs can't be MODE_INT and will abort.  Just put
+            that these regs can't be MODE_INT and will assert.  Just put
             the right reg there without calling replace_reg.  */
 
          *clobber_loc[i] = FP_MODE_REG (regnum, DFmode);
@@ -2423,7 +2343,7 @@ subst_stack_regs (rtx insn, stack regstack)
 
    Insert any needed insns before or after INSN, as indicated by
    WHERE.  OLD is the original stack layout, and NEW is the desired
-   form.  OLD is updated to reflect the code emitted, ie, it will be
+   form.  OLD is updated to reflect the code emitted, i.e., it will be
    the same as NEW upon return.
 
    This function will not preserve block_end[].  But that information
@@ -2447,10 +2367,66 @@ change_stack (rtx insn, stack old, stack new, enum emit_where where)
 
   /* Pop any registers that are not needed in the new block.  */
 
-  for (reg = old->top; reg >= 0; reg--)
-    if (! TEST_HARD_REG_BIT (new->reg_set, old->reg[reg]))
-      emit_pop_insn (insn, old, FP_MODE_REG (old->reg[reg], DFmode),
-                    EMIT_BEFORE);
+  /* If the destination block's stack already has a specified layout
+     and contains two or more registers, use a more intelligent algorithm
+     to pop registers that minimizes the number number of fxchs below.  */
+  if (new->top > 0)
+    {
+      bool slots[REG_STACK_SIZE];
+      int pops[REG_STACK_SIZE];
+      int next, dest;
+
+      /* First pass to determine the free slots.  */
+      for (reg = 0; reg <= new->top; reg++)
+       slots[reg] = TEST_HARD_REG_BIT (new->reg_set, old->reg[reg]);
+
+      /* Second pass to allocate preferred slots.  */
+      for (reg = old->top; reg > new->top; reg--)
+       if (TEST_HARD_REG_BIT (new->reg_set, old->reg[reg]))
+         {
+           dest = -1;
+           for (next = 0; next <= new->top; next++)
+             if (!slots[next] && new->reg[next] == old->reg[reg])
+               {
+                 slots[next] = true;
+                 dest = next;
+                 break;
+               }
+           pops[reg] = dest;
+         }
+       else
+         pops[reg] = reg;
+
+      /* Third pass allocates remaining slots and emits pop insns.  */
+      next = 0;
+      for (reg = old->top; reg > new->top; reg--)
+       {
+         dest = pops[reg];
+         if (dest == -1)
+           {
+             /* Find next free slot.  */
+             while (slots[next])
+               next++;
+             dest = next++;
+           }
+         emit_pop_insn (insn, old, FP_MODE_REG (old->reg[dest], DFmode),
+                        EMIT_BEFORE);
+       }
+    }
+  else
+    /* The following loop attempts to maximize the number of times we
+       pop the top of the stack, as this permits the use of the faster
+       ffreep instruction on platforms that support it.  */
+    for (reg = 0; reg <= old->top; reg++)
+      if (! TEST_HARD_REG_BIT (new->reg_set, old->reg[reg]))
+       {
+         while (old->top > reg
+                && ! TEST_HARD_REG_BIT (new->reg_set, old->reg[old->top]))
+           emit_pop_insn (insn, old, FP_MODE_REG (old->reg[old->top], DFmode),
+                          EMIT_BEFORE);
+         emit_pop_insn (insn, old, FP_MODE_REG (old->reg[reg], DFmode),
+                        EMIT_BEFORE);
+       }
 
   if (new->top == -2)
     {
@@ -2469,10 +2445,9 @@ change_stack (rtx insn, stack old, stack new, enum emit_where where)
         not their depth or liveliness.  */
 
       GO_IF_HARD_REG_EQUAL (old->reg_set, new->reg_set, win);
-      abort ();
+      gcc_unreachable ();
     win:
-      if (old->top != new->top)
-       abort ();
+      gcc_assert (old->top == new->top);
 
       /* If the stack is not empty (new->top != -1), loop here emitting
         swaps until the stack is correct.
@@ -2495,8 +2470,7 @@ change_stack (rtx insn, stack old, stack new, enum emit_where where)
                  if (new->reg[reg] == old->reg[old->top])
                    break;
 
-               if (reg == -1)
-                 abort ();
+               gcc_assert (reg != -1);
 
                emit_swap_insn (insn, old,
                                FP_MODE_REG (old->reg[reg], DFmode));
@@ -2518,8 +2492,7 @@ change_stack (rtx insn, stack old, stack new, enum emit_where where)
       /* At this point there must be no differences.  */
 
       for (reg = old->top; reg >= 0; reg--)
-       if (old->reg[reg] != new->reg[reg])
-         abort ();
+       gcc_assert (old->reg[reg] == new->reg[reg]);
     }
 
   if (update_end)
@@ -2561,6 +2534,7 @@ convert_regs_entry (void)
 {
   int inserted = 0;
   edge e;
+  edge_iterator ei;
   basic_block block;
 
   FOR_EACH_BB_REVERSE (block)
@@ -2590,7 +2564,7 @@ convert_regs_entry (void)
      Note that we are inserting converted code here.  This code is
      never seen by the convert_regs pass.  */
 
-  for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
+  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
     {
       basic_block block = e->dest;
       block_info bi = BLOCK_INFO (block);
@@ -2731,7 +2705,7 @@ compensate_edge (edge e, FILE *file)
 
       CLEAR_HARD_REG_SET (tmp);
       GO_IF_HARD_REG_EQUAL (target_stack->reg_set, tmp, eh1);
-      abort ();
+      gcc_unreachable ();
     eh1:
 
       /* We are sure that there is st(0) live, otherwise we won't compensate.
@@ -2740,7 +2714,7 @@ compensate_edge (edge e, FILE *file)
       if (TEST_HARD_REG_BIT (regstack.reg_set, FIRST_STACK_REG + 1))
         SET_HARD_REG_BIT (tmp, FIRST_STACK_REG + 1);
       GO_IF_HARD_REG_EQUAL (regstack.reg_set, tmp, eh2);
-      abort ();
+      gcc_unreachable ();
     eh2:
 
       target_stack->top = -1;
@@ -2750,7 +2724,7 @@ compensate_edge (edge e, FILE *file)
      instead of to the edge, because emit_swap can do minimal
      insn scheduling.  We can do this when there is only one
      edge out, and it is not abnormal.  */
-  else if (block->succ->succ_next == NULL && !(e->flags & EDGE_ABNORMAL))
+  else if (EDGE_COUNT (block->succs) == 1 && !(e->flags & EDGE_ABNORMAL))
     {
       /* change_stack kills values in regstack.  */
       tmpstack = regstack;
@@ -2766,8 +2740,7 @@ compensate_edge (edge e, FILE *file)
       /* We don't support abnormal edges.  Global takes care to
          avoid any live register across them, so we should never
          have to insert instructions on such edges.  */
-      if (e->flags & EDGE_ABNORMAL)
-       abort ();
+      gcc_assert (!(e->flags & EDGE_ABNORMAL));
 
       current_block = NULL;
       start_sequence ();
@@ -2798,6 +2771,7 @@ convert_regs_1 (FILE *file, basic_block block)
   rtx insn, next;
   edge e, beste = NULL;
   bool control_flow_insn_deleted = false;
+  edge_iterator ei;
 
   inserted = 0;
   deleted = 0;
@@ -2808,7 +2782,7 @@ convert_regs_1 (FILE *file, basic_block block)
      if multiple such exists, take one with largest count, prefer critical
      one (as splitting critical edges is more expensive), or one with lowest
      index, to avoid random changes with different orders of the edges.  */
-  for (e = block->pred; e ; e = e->pred_next)
+  FOR_EACH_EDGE (e, ei, block->preds)
     {
       if (e->flags & EDGE_DFS_BACK)
        ;
@@ -2870,8 +2844,7 @@ convert_regs_1 (FILE *file, basic_block block)
       next = NEXT_INSN (insn);
 
       /* Ensure we have not missed a block boundary.  */
-      if (next == NULL)
-       abort ();
+      gcc_assert (next);
       if (insn == BB_END (block))
        next = NULL;
 
@@ -2953,30 +2926,27 @@ convert_regs_1 (FILE *file, basic_block block)
      asms, we zapped the instruction itself, but that didn't produce the
      same pattern of register kills as before.  */
   GO_IF_HARD_REG_EQUAL (regstack.reg_set, bi->out_reg_set, win);
-  if (!any_malformed_asm)
-    abort ();
+  gcc_assert (any_malformed_asm);
  win:
   bi->stack_out = regstack;
 
   /* Compensate the back edges, as those wasn't visited yet.  */
-  for (e = block->succ; e ; e = e->succ_next)
+  FOR_EACH_EDGE (e, ei, block->succs)
     {
       if (e->flags & EDGE_DFS_BACK
          || (e->dest == EXIT_BLOCK_PTR))
        {
-         if (!BLOCK_INFO (e->dest)->done
-             && e->dest != block)
-           abort ();
+         gcc_assert (BLOCK_INFO (e->dest)->done
+                     || e->dest == block);
          inserted |= compensate_edge (e, file);
        }
     }
-  for (e = block->pred; e ; e = e->pred_next)
+  FOR_EACH_EDGE (e, ei, block->preds)
     {
       if (e != beste && !(e->flags & EDGE_DFS_BACK)
          && e->src != ENTRY_BLOCK_PTR)
        {
-         if (!BLOCK_INFO (e->src)->done)
-           abort ();
+         gcc_assert (BLOCK_INFO (e->src)->done);
          inserted |= compensate_edge (e, file);
        }
     }
@@ -3005,6 +2975,7 @@ convert_regs_2 (FILE *file, basic_block block)
   do
     {
       edge e;
+      edge_iterator ei;
 
       block = *--sp;
 
@@ -3021,12 +2992,12 @@ convert_regs_2 (FILE *file, basic_block block)
         stack the successor in all cases and hand over the task of
         fixing up the discrepancy to convert_regs_1.  */
 
-      for (e = block->succ; e ; e = e->succ_next)
+      FOR_EACH_EDGE (e, ei, block->succs)
        if (! (e->flags & EDGE_DFS_BACK))
          {
            BLOCK_INFO (e->dest)->predecessors--;
            if (!BLOCK_INFO (e->dest)->predecessors)
-              *sp++ = e->dest;
+             *sp++ = e->dest;
          }
 
       inserted |= convert_regs_1 (file, block);
@@ -3047,6 +3018,7 @@ convert_regs (FILE *file)
   int inserted;
   basic_block b;
   edge e;
+  edge_iterator ei;
 
   /* Initialize uninitialized registers on function entry.  */
   inserted = convert_regs_entry ();
@@ -3060,7 +3032,7 @@ convert_regs (FILE *file)
      prevent double fxch that often appears at the head of a loop.  */
 
   /* Process all blocks reachable from all entry points.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
+  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
     inserted |= convert_regs_2 (file, e->dest);
 
   /* ??? Process all unreachable blocks.  Though there's no excuse