OSDN Git Service

* config/avr/avr-protos.h (avr_output_addr_vec_elt): Prototype.
[pf3gnuchains/gcc-fork.git] / gcc / reload.c
index 922f905..86d80c1 100644 (file)
@@ -1,5 +1,6 @@
 /* Search an insn for pseudo regs that must be in hard regs and are not.
-   Copyright (C) 1987, 88, 89, 92-97, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+   1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -18,7 +19,6 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-
 /* This file contains subroutines used only from the file reload1.c.
    It knows how to scan one insn for operands and values
    that need to be copied into registers to make valid code.
@@ -70,7 +70,6 @@ NOTE SIDE EFFECTS:
 2 happens only when REPLACE is 1, which is only when
 actually doing the reloads, not when just counting them.
 
-
 Using a reload register for several reloads in one insn:
 
 When an insn has reloads, it is considered as having three parts:
@@ -90,6 +89,7 @@ a register with any other reload.  */
 #include "config.h"
 #include "system.h"
 #include "rtl.h"
+#include "tm_p.h"
 #include "insn-config.h"
 #include "insn-codes.h"
 #include "recog.h"
@@ -99,6 +99,7 @@ a register with any other reload.  */
 #include "flags.h"
 #include "real.h"
 #include "output.h"
+#include "function.h"
 #include "expr.h"
 #include "toplev.h"
 
@@ -114,82 +115,10 @@ a register with any other reload.  */
 #define REG_MODE_OK_FOR_BASE_P(REGNO, MODE) REG_OK_FOR_BASE_P (REGNO)
 #endif
 \f
-/* The variables set up by `find_reloads' are:
-
-   n_reloads             number of distinct reloads needed; max reload # + 1
-       tables indexed by reload number
-   reload_in             rtx for value to reload from
-   reload_out            rtx for where to store reload-reg afterward if nec
-                          (often the same as reload_in)
-   reload_reg_class      enum reg_class, saying what regs to reload into
-   reload_inmode         enum machine_mode; mode this operand should have
-                          when reloaded, on input.
-   reload_outmode        enum machine_mode; mode this operand should have
-                          when reloaded, on output.
-   reload_optional       char, nonzero for an optional reload.
-                          Optional reloads are ignored unless the
-                          value is already sitting in a register.
-   reload_nongroup       char, nonzero when a reload must use a register
-                          not already allocated to a group.
-   reload_inc            int, positive amount to increment or decrement by if
-                          reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC.
-                          Ignored otherwise (don't assume it is zero).
-   reload_in_reg         rtx.  A reg for which reload_in is the equivalent.
-                          If reload_in is a symbol_ref which came from
-                          reg_equiv_constant, then this is the pseudo
-                          which has that symbol_ref as equivalent.
-   reload_reg_rtx        rtx.  This is the register to reload into.
-                          If it is zero when `find_reloads' returns,
-                          you must find a suitable register in the class
-                          specified by reload_reg_class, and store here
-                          an rtx for that register with mode from
-                          reload_inmode or reload_outmode.
-   reload_nocombine      char, nonzero if this reload shouldn't be
-                          combined with another reload.
-   reload_opnum                  int, operand number being reloaded.  This is
-                          used to group related reloads and need not always
-                          be equal to the actual operand number in the insn,
-                          though it current will be; for in-out operands, it
-                          is one of the two operand numbers.
-   reload_when_needed    enum, classifies reload as needed either for
-                          addressing an input reload, addressing an output,
-                          for addressing a non-reloaded mem ref,
-                          or for unspecified purposes (i.e., more than one
-                          of the above).
-   reload_secondary_p    int, 1 if this is a secondary register for one
-                          or more reloads.
-   reload_secondary_in_reload
-   reload_secondary_out_reload
-                         int, gives the reload number of a secondary
-                          reload, when needed; otherwise -1
-   reload_secondary_in_icode
-   reload_secondary_out_icode
-                         enum insn_code, if a secondary reload is required,
-                          gives the INSN_CODE that uses the secondary
-                          reload as a scratch register, or CODE_FOR_nothing
-                          if the secondary reload register is to be an
-                          intermediate register.  */
+/* All reloads of the current insn are recorded here.  See reload.h for
+   comments.  */
 int n_reloads;
-
-rtx reload_in[MAX_RELOADS];
-rtx reload_out[MAX_RELOADS];
-enum reg_class reload_reg_class[MAX_RELOADS];
-enum machine_mode reload_inmode[MAX_RELOADS];
-enum machine_mode reload_outmode[MAX_RELOADS];
-rtx reload_reg_rtx[MAX_RELOADS];
-char reload_optional[MAX_RELOADS];
-char reload_nongroup[MAX_RELOADS];
-int reload_inc[MAX_RELOADS];
-rtx reload_in_reg[MAX_RELOADS];
-rtx reload_out_reg[MAX_RELOADS];
-char reload_nocombine[MAX_RELOADS];
-int reload_opnum[MAX_RELOADS];
-enum reload_type reload_when_needed[MAX_RELOADS];
-int reload_secondary_p[MAX_RELOADS];
-int reload_secondary_in_reload[MAX_RELOADS];
-int reload_secondary_out_reload[MAX_RELOADS];
-enum insn_code reload_secondary_in_icode[MAX_RELOADS];
-enum insn_code reload_secondary_out_icode[MAX_RELOADS];
+struct reload rld[MAX_RELOADS];
 
 /* All the "earlyclobber" operands of the current insn
    are recorded here.  */
@@ -236,9 +165,9 @@ struct decomposition
 #ifdef SECONDARY_MEMORY_NEEDED
 
 /* Save MEMs needed to copy from one class of registers to another.  One MEM
-   is used per mode, but normally only one or two modes are ever used.  
+   is used per mode, but normally only one or two modes are ever used.
 
-   We keep two versions, before and after register elimination.  The one 
+   We keep two versions, before and after register elimination.  The one
    after register elimination is record separately for each operand.  This
    is done in case the address is not valid to be sure that we separately
    reload each.  */
@@ -307,37 +236,41 @@ static int output_reloadnum;
       : (type)))
 
 #ifdef HAVE_SECONDARY_RELOADS
-static int push_secondary_reload PROTO((int, rtx, int, int, enum reg_class,
+static int push_secondary_reload PARAMS ((int, rtx, int, int, enum reg_class,
                                        enum machine_mode, enum reload_type,
                                        enum insn_code *));
 #endif
-static enum reg_class find_valid_class PROTO((enum machine_mode, int));
-static int push_reload         PROTO((rtx, rtx, rtx *, rtx *, enum reg_class,
+static enum reg_class find_valid_class PARAMS ((enum machine_mode, int));
+static int reload_inner_reg_of_subreg PARAMS ((rtx, enum machine_mode));
+static int push_reload         PARAMS ((rtx, rtx, rtx *, rtx *, enum reg_class,
                                       enum machine_mode, enum machine_mode,
                                       int, int, int, enum reload_type));
-static void push_replacement   PROTO((rtx *, int, enum machine_mode));
-static void combine_reloads    PROTO((void));
-static rtx find_dummy_reload   PROTO((rtx, rtx, rtx *, rtx *,
+static void push_replacement   PARAMS ((rtx *, int, enum machine_mode));
+static void combine_reloads    PARAMS ((void));
+static int find_reusable_reload        PARAMS ((rtx *, rtx, enum reg_class,
+                                      enum reload_type, int, int));
+static rtx find_dummy_reload   PARAMS ((rtx, rtx, rtx *, rtx *,
                                       enum machine_mode, enum machine_mode,
                                       enum reg_class, int, int));
-static int earlyclobber_operand_p PROTO((rtx));
-static int hard_reg_set_here_p PROTO((int, int, rtx));
-static struct decomposition decompose PROTO((rtx));
-static int immune_p            PROTO((rtx, rtx, struct decomposition));
-static int alternative_allows_memconst PROTO((char *, int));
-static rtx find_reloads_toplev PROTO((rtx, int, enum reload_type, int, int, rtx));
-static rtx make_memloc         PROTO((rtx, int));
-static int find_reloads_address        PROTO((enum machine_mode, rtx *, rtx, rtx *,
+static int hard_reg_set_here_p PARAMS ((unsigned int, unsigned int, rtx));
+static struct decomposition decompose PARAMS ((rtx));
+static int immune_p            PARAMS ((rtx, rtx, struct decomposition));
+static int alternative_allows_memconst PARAMS ((const char *, int));
+static rtx find_reloads_toplev PARAMS ((rtx, int, enum reload_type, int,
+                                        int, rtx, int *));
+static rtx make_memloc         PARAMS ((rtx, int));
+static int find_reloads_address        PARAMS ((enum machine_mode, rtx *, rtx, rtx *,
                                       int, enum reload_type, int, rtx));
-static rtx subst_reg_equivs    PROTO((rtx, rtx));
-static rtx subst_indexed_address PROTO((rtx));
-static int find_reloads_address_1 PROTO((enum machine_mode, rtx, int, rtx *,
+static rtx subst_reg_equivs    PARAMS ((rtx, rtx));
+static rtx subst_indexed_address PARAMS ((rtx));
+static int find_reloads_address_1 PARAMS ((enum machine_mode, rtx, int, rtx *,
                                         int, enum reload_type,int, rtx));
-static void find_reloads_address_part PROTO((rtx, rtx *, enum reg_class,
+static void find_reloads_address_part PARAMS ((rtx, rtx *, enum reg_class,
                                             enum machine_mode, int,
                                             enum reload_type, int));
-static int find_inc_amount     PROTO((rtx, rtx));
-static int loc_mentioned_in_p  PROTO((rtx *, rtx));
+static rtx find_reloads_subreg_address PARAMS ((rtx, int, int, enum reload_type,
+                                             int, rtx));
+static int find_inc_amount     PARAMS ((rtx, rtx));
 \f
 #ifdef HAVE_SECONDARY_RELOADS
 
@@ -422,8 +355,8 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
           : reload_out_optab[(int) reload_mode]);
 
   if (icode != CODE_FOR_nothing
-      && insn_operand_predicate[(int) icode][in_p]
-      && (! (insn_operand_predicate[(int) icode][in_p]) (x, reload_mode)))
+      && insn_data[(int) icode].operand[in_p].predicate
+      && (! (insn_data[(int) icode].operand[in_p].predicate) (x, reload_mode)))
     icode = CODE_FOR_nothing;
 
   /* If we will be using an insn, see if it can directly handle the reload
@@ -434,30 +367,32 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
 
   if (icode != CODE_FOR_nothing)
     {
-      /* If IN_P is non-zero, the reload register will be the output in 
+      /* If IN_P is non-zero, the reload register will be the output in
         operand 0.  If IN_P is zero, the reload register will be the input
         in operand 1.  Outputs should have an initial "=", which we must
         skip.  */
 
-      char insn_letter = insn_operand_constraint[(int) icode][!in_p][in_p];
+      char insn_letter
+       = insn_data[(int) icode].operand[!in_p].constraint[in_p];
       enum reg_class insn_class
        = (insn_letter == 'r' ? GENERAL_REGS
           : REG_CLASS_FROM_LETTER ((unsigned char) insn_letter));
 
       if (insn_class == NO_REGS
-         || (in_p && insn_operand_constraint[(int) icode][!in_p][0] != '=')
+         || (in_p
+             && insn_data[(int) icode].operand[!in_p].constraint[0] != '=')
          /* The scratch register's constraint must start with "=&".  */
-         || insn_operand_constraint[(int) icode][2][0] != '='
-         || insn_operand_constraint[(int) icode][2][1] != '&')
+         || insn_data[(int) icode].operand[2].constraint[0] != '='
+         || insn_data[(int) icode].operand[2].constraint[1] != '&')
        abort ();
 
       if (reg_class_subset_p (reload_class, insn_class))
-       mode = insn_operand_mode[(int) icode][2];
+       mode = insn_data[(int) icode].operand[2].mode;
       else
        {
-         char t_letter = insn_operand_constraint[(int) icode][2][2];
+         char t_letter = insn_data[(int) icode].operand[2].constraint[2];
          class = insn_class;
-         t_mode = insn_operand_mode[(int) icode][2];
+         t_mode = insn_data[(int) icode].operand[2].mode;
          t_class = (t_letter == 'r' ? GENERAL_REGS
                     : REG_CLASS_FROM_LETTER ((unsigned char) t_letter));
          t_icode = icode;
@@ -476,11 +411,11 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
      can not use secondary reloads, you must work around the problem some
      other way.
 
-     Allow this when MODE is not reload_mode and assume that the generated
-     code handles this case (it does on the Alpha, which is the only place
-     this currently happens).  */
+     Allow this when a reload_in/out pattern is being used.  I.e. assume
+     that the generated code handles this case.  */
 
-  if (in_p && class == reload_class && mode == reload_mode)
+  if (in_p && class == reload_class && icode == CODE_FOR_nothing
+      && t_icode == CODE_FOR_nothing)
     abort ();
 
   /* If we need a tertiary reload, see if we have one we can reuse or else
@@ -489,58 +424,57 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
   if (t_class != NO_REGS)
     {
       for (t_reload = 0; t_reload < n_reloads; t_reload++)
-       if (reload_secondary_p[t_reload]
-           && (reg_class_subset_p (t_class, reload_reg_class[t_reload])
-               || reg_class_subset_p (reload_reg_class[t_reload], t_class))
-           && ((in_p && reload_inmode[t_reload] == t_mode)
-               || (! in_p && reload_outmode[t_reload] == t_mode))
-           && ((in_p && (reload_secondary_in_icode[t_reload]
+       if (rld[t_reload].secondary_p
+           && (reg_class_subset_p (t_class, rld[t_reload].class)
+               || reg_class_subset_p (rld[t_reload].class, t_class))
+           && ((in_p && rld[t_reload].inmode == t_mode)
+               || (! in_p && rld[t_reload].outmode == t_mode))
+           && ((in_p && (rld[t_reload].secondary_in_icode
                          == CODE_FOR_nothing))
-               || (! in_p &&(reload_secondary_out_icode[t_reload]
+               || (! in_p &&(rld[t_reload].secondary_out_icode
                              == CODE_FOR_nothing)))
            && (reg_class_size[(int) t_class] == 1 || SMALL_REGISTER_CLASSES)
            && MERGABLE_RELOADS (secondary_type,
-                                reload_when_needed[t_reload],
-                                opnum, reload_opnum[t_reload]))
+                                rld[t_reload].when_needed,
+                                opnum, rld[t_reload].opnum))
          {
            if (in_p)
-             reload_inmode[t_reload] = t_mode;
+             rld[t_reload].inmode = t_mode;
            if (! in_p)
-             reload_outmode[t_reload] = t_mode;
+             rld[t_reload].outmode = t_mode;
 
-           if (reg_class_subset_p (t_class, reload_reg_class[t_reload]))
-             reload_reg_class[t_reload] = t_class;
+           if (reg_class_subset_p (t_class, rld[t_reload].class))
+             rld[t_reload].class = t_class;
 
-           reload_opnum[t_reload] = MIN (reload_opnum[t_reload], opnum);
-           reload_optional[t_reload] &= optional;
-           reload_secondary_p[t_reload] = 1;
-           if (MERGE_TO_OTHER (secondary_type, reload_when_needed[t_reload],
-                               opnum, reload_opnum[t_reload]))
-             reload_when_needed[t_reload] = RELOAD_OTHER;
+           rld[t_reload].opnum = MIN (rld[t_reload].opnum, opnum);
+           rld[t_reload].optional &= optional;
+           rld[t_reload].secondary_p = 1;
+           if (MERGE_TO_OTHER (secondary_type, rld[t_reload].when_needed,
+                               opnum, rld[t_reload].opnum))
+             rld[t_reload].when_needed = RELOAD_OTHER;
          }
 
       if (t_reload == n_reloads)
        {
          /* We need to make a new tertiary reload for this register class.  */
-         reload_in[t_reload] = reload_out[t_reload] = 0;
-         reload_reg_class[t_reload] = t_class;
-         reload_inmode[t_reload] = in_p ? t_mode : VOIDmode;
-         reload_outmode[t_reload] = ! in_p ? t_mode : VOIDmode;
-         reload_reg_rtx[t_reload] = 0;
-         reload_optional[t_reload] = optional;
-         reload_nongroup[t_reload] = 0;
-         reload_inc[t_reload] = 0;
+         rld[t_reload].in = rld[t_reload].out = 0;
+         rld[t_reload].class = t_class;
+         rld[t_reload].inmode = in_p ? t_mode : VOIDmode;
+         rld[t_reload].outmode = ! in_p ? t_mode : VOIDmode;
+         rld[t_reload].reg_rtx = 0;
+         rld[t_reload].optional = optional;
+         rld[t_reload].inc = 0;
          /* Maybe we could combine these, but it seems too tricky.  */
-         reload_nocombine[t_reload] = 1;
-         reload_in_reg[t_reload] = 0;
-         reload_out_reg[t_reload] = 0;
-         reload_opnum[t_reload] = opnum;
-         reload_when_needed[t_reload] = secondary_type;
-         reload_secondary_in_reload[t_reload] = -1;
-         reload_secondary_out_reload[t_reload] = -1;
-         reload_secondary_in_icode[t_reload] = CODE_FOR_nothing;
-         reload_secondary_out_icode[t_reload] = CODE_FOR_nothing;
-         reload_secondary_p[t_reload] = 1;
+         rld[t_reload].nocombine = 1;
+         rld[t_reload].in_reg = 0;
+         rld[t_reload].out_reg = 0;
+         rld[t_reload].opnum = opnum;
+         rld[t_reload].when_needed = secondary_type;
+         rld[t_reload].secondary_in_reload = -1;
+         rld[t_reload].secondary_out_reload = -1;
+         rld[t_reload].secondary_in_icode = CODE_FOR_nothing;
+         rld[t_reload].secondary_out_icode = CODE_FOR_nothing;
+         rld[t_reload].secondary_p = 1;
 
          n_reloads++;
        }
@@ -548,33 +482,33 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
 
   /* See if we can reuse an existing secondary reload.  */
   for (s_reload = 0; s_reload < n_reloads; s_reload++)
-    if (reload_secondary_p[s_reload]
-       && (reg_class_subset_p (class, reload_reg_class[s_reload])
-           || reg_class_subset_p (reload_reg_class[s_reload], class))
-       && ((in_p && reload_inmode[s_reload] == mode)
-           || (! in_p && reload_outmode[s_reload] == mode))
-       && ((in_p && reload_secondary_in_reload[s_reload] == t_reload)
-           || (! in_p && reload_secondary_out_reload[s_reload] == t_reload))
-       && ((in_p && reload_secondary_in_icode[s_reload] == t_icode)
-           || (! in_p && reload_secondary_out_icode[s_reload] == t_icode))
+    if (rld[s_reload].secondary_p
+       && (reg_class_subset_p (class, rld[s_reload].class)
+           || reg_class_subset_p (rld[s_reload].class, class))
+       && ((in_p && rld[s_reload].inmode == mode)
+           || (! in_p && rld[s_reload].outmode == mode))
+       && ((in_p && rld[s_reload].secondary_in_reload == t_reload)
+           || (! in_p && rld[s_reload].secondary_out_reload == t_reload))
+       && ((in_p && rld[s_reload].secondary_in_icode == t_icode)
+           || (! in_p && rld[s_reload].secondary_out_icode == t_icode))
        && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
-       && MERGABLE_RELOADS (secondary_type, reload_when_needed[s_reload],
-                            opnum, reload_opnum[s_reload]))
+       && MERGABLE_RELOADS (secondary_type, rld[s_reload].when_needed,
+                            opnum, rld[s_reload].opnum))
       {
        if (in_p)
-         reload_inmode[s_reload] = mode;
+         rld[s_reload].inmode = mode;
        if (! in_p)
-         reload_outmode[s_reload] = mode;
+         rld[s_reload].outmode = mode;
 
-       if (reg_class_subset_p (class, reload_reg_class[s_reload]))
-         reload_reg_class[s_reload] = class;
+       if (reg_class_subset_p (class, rld[s_reload].class))
+         rld[s_reload].class = class;
 
-       reload_opnum[s_reload] = MIN (reload_opnum[s_reload], opnum);
-       reload_optional[s_reload] &= optional;
-       reload_secondary_p[s_reload] = 1;
-       if (MERGE_TO_OTHER (secondary_type, reload_when_needed[s_reload],
-                           opnum, reload_opnum[s_reload]))
-         reload_when_needed[s_reload] = RELOAD_OTHER;
+       rld[s_reload].opnum = MIN (rld[s_reload].opnum, opnum);
+       rld[s_reload].optional &= optional;
+       rld[s_reload].secondary_p = 1;
+       if (MERGE_TO_OTHER (secondary_type, rld[s_reload].when_needed,
+                           opnum, rld[s_reload].opnum))
+         rld[s_reload].when_needed = RELOAD_OTHER;
       }
 
   if (s_reload == n_reloads)
@@ -582,36 +516,41 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
 #ifdef SECONDARY_MEMORY_NEEDED
       /* If we need a memory location to copy between the two reload regs,
         set it up now.  Note that we do the input case before making
-        the reload and the output case after.  This is due to the 
+        the reload and the output case after.  This is due to the
         way reloads are output.  */
 
       if (in_p && icode == CODE_FOR_nothing
          && SECONDARY_MEMORY_NEEDED (class, reload_class, mode))
-       get_secondary_mem (x, reload_mode, opnum, type);
+       {
+         get_secondary_mem (x, reload_mode, opnum, type);
+
+         /* We may have just added new reloads.  Make sure we add
+            the new reload at the end.  */
+         s_reload = n_reloads;
+       }
 #endif
 
       /* We need to make a new secondary reload for this register class.  */
-      reload_in[s_reload] = reload_out[s_reload] = 0;
-      reload_reg_class[s_reload] = class;
-
-      reload_inmode[s_reload] = in_p ? mode : VOIDmode;
-      reload_outmode[s_reload] = ! in_p ? mode : VOIDmode;
-      reload_reg_rtx[s_reload] = 0;
-      reload_optional[s_reload] = optional;
-      reload_nongroup[s_reload] = 0;
-      reload_inc[s_reload] = 0;
+      rld[s_reload].in = rld[s_reload].out = 0;
+      rld[s_reload].class = class;
+
+      rld[s_reload].inmode = in_p ? mode : VOIDmode;
+      rld[s_reload].outmode = ! in_p ? mode : VOIDmode;
+      rld[s_reload].reg_rtx = 0;
+      rld[s_reload].optional = optional;
+      rld[s_reload].inc = 0;
       /* Maybe we could combine these, but it seems too tricky.  */
-      reload_nocombine[s_reload] = 1;
-      reload_in_reg[s_reload] = 0;
-      reload_out_reg[s_reload] = 0;
-      reload_opnum[s_reload] = opnum;
-      reload_when_needed[s_reload] = secondary_type;
-      reload_secondary_in_reload[s_reload] = in_p ? t_reload : -1;
-      reload_secondary_out_reload[s_reload] = ! in_p ? t_reload : -1;
-      reload_secondary_in_icode[s_reload] = in_p ? t_icode : CODE_FOR_nothing; 
-      reload_secondary_out_icode[s_reload]
+      rld[s_reload].nocombine = 1;
+      rld[s_reload].in_reg = 0;
+      rld[s_reload].out_reg = 0;
+      rld[s_reload].opnum = opnum;
+      rld[s_reload].when_needed = secondary_type;
+      rld[s_reload].secondary_in_reload = in_p ? t_reload : -1;
+      rld[s_reload].secondary_out_reload = ! in_p ? t_reload : -1;
+      rld[s_reload].secondary_in_icode = in_p ? t_icode : CODE_FOR_nothing;
+      rld[s_reload].secondary_out_icode
        = ! in_p ? t_icode : CODE_FOR_nothing;
-      reload_secondary_p[s_reload] = 1;
+      rld[s_reload].secondary_p = 1;
 
       n_reloads++;
 
@@ -629,13 +568,13 @@ push_secondary_reload (in_p, x, opnum, optional, reload_class, reload_mode,
 \f
 #ifdef SECONDARY_MEMORY_NEEDED
 
-/* Return a memory location that will be used to copy X in mode MODE.  
+/* Return a memory location that will be used to copy X in mode MODE.
    If we haven't already made a location for this mode in this insn,
    call find_reloads_address on the location being returned.  */
 
 rtx
 get_secondary_mem (x, mode, opnum, type)
-     rtx x;
+     rtx x ATTRIBUTE_UNUSED;
      enum machine_mode mode;
      int opnum;
      enum reload_type type;
@@ -651,7 +590,7 @@ get_secondary_mem (x, mode, opnum, type)
 #ifdef SECONDARY_MEMORY_NEEDED_MODE
   mode = SECONDARY_MEMORY_NEEDED_MODE (mode);
 #else
-  if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD)
+  if (GET_MODE_BITSIZE (mode) < BITS_PER_WORD && INTEGRAL_MODE_P (mode))
     mode = mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (mode), 0);
 #endif
 
@@ -659,7 +598,7 @@ get_secondary_mem (x, mode, opnum, type)
   if (secondary_memlocs_elim[(int) mode][opnum] != 0)
     return secondary_memlocs_elim[(int) mode][opnum];
 
-  /* If this is the first time we've tried to get a MEM for this mode, 
+  /* If this is the first time we've tried to get a MEM for this mode,
      allocate a new one.  `something_changed' in reload will get set
      by noticing that the frame size has changed.  */
 
@@ -708,7 +647,7 @@ get_secondary_mem (x, mode, opnum, type)
 void
 clear_secondary_mem ()
 {
-  bzero ((char *) secondary_memlocs, sizeof secondary_memlocs);
+  memset ((char *) secondary_memlocs, 0, sizeof secondary_memlocs);
 }
 #endif /* SECONDARY_MEMORY_NEEDED */
 \f
@@ -717,13 +656,13 @@ clear_secondary_mem ()
 
 static enum reg_class
 find_valid_class (m1, n)
-     enum machine_mode  m1;
+     enum machine_mode m1 ATTRIBUTE_UNUSED;
      int n;
 {
   int class;
   int regno;
-  enum reg_class best_class;
-  int best_size = 0;
+  enum reg_class best_class = NO_REGS;
+  unsigned int best_size = 0;
 
   for (class = 1; class < N_REG_CLASSES; class++)
     {
@@ -744,6 +683,126 @@ find_valid_class (m1, n)
   return best_class;
 }
 \f
+/* Return the number of a previously made reload that can be combined with
+   a new one, or n_reloads if none of the existing reloads can be used.
+   OUT, CLASS, TYPE and OPNUM are the same arguments as passed to
+   push_reload, they determine the kind of the new reload that we try to
+   combine.  P_IN points to the corresponding value of IN, which can be
+   modified by this function.
+   DONT_SHARE is nonzero if we can't share any input-only reload for IN.  */
+static int
+find_reusable_reload (p_in, out, class, type, opnum, dont_share)
+     rtx *p_in, out;
+     enum reg_class class;
+     enum reload_type type;
+     int opnum, dont_share;
+{
+  rtx in = *p_in;
+  int i;
+  /* We can't merge two reloads if the output of either one is
+     earlyclobbered.  */
+
+  if (earlyclobber_operand_p (out))
+    return n_reloads;
+
+  /* We can use an existing reload if the class is right
+     and at least one of IN and OUT is a match
+     and the other is at worst neutral.
+     (A zero compared against anything is neutral.)
+
+     If SMALL_REGISTER_CLASSES, don't use existing reloads unless they are
+     for the same thing since that can cause us to need more reload registers
+     than we otherwise would.  */
+
+  for (i = 0; i < n_reloads; i++)
+    if ((reg_class_subset_p (class, rld[i].class)
+        || reg_class_subset_p (rld[i].class, class))
+       /* If the existing reload has a register, it must fit our class.  */
+       && (rld[i].reg_rtx == 0
+           || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
+                                 true_regnum (rld[i].reg_rtx)))
+       && ((in != 0 && MATCHES (rld[i].in, in) && ! dont_share
+            && (out == 0 || rld[i].out == 0 || MATCHES (rld[i].out, out)))
+           || (out != 0 && MATCHES (rld[i].out, out)
+               && (in == 0 || rld[i].in == 0 || MATCHES (rld[i].in, in))))
+       && (rld[i].out == 0 || ! earlyclobber_operand_p (rld[i].out))
+       && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
+       && MERGABLE_RELOADS (type, rld[i].when_needed, opnum, rld[i].opnum))
+      return i;
+
+  /* Reloading a plain reg for input can match a reload to postincrement
+     that reg, since the postincrement's value is the right value.
+     Likewise, it can match a preincrement reload, since we regard
+     the preincrementation as happening before any ref in this insn
+     to that register.  */
+  for (i = 0; i < n_reloads; i++)
+    if ((reg_class_subset_p (class, rld[i].class)
+        || reg_class_subset_p (rld[i].class, class))
+       /* If the existing reload has a register, it must fit our
+          class.  */
+       && (rld[i].reg_rtx == 0
+           || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
+                                 true_regnum (rld[i].reg_rtx)))
+       && out == 0 && rld[i].out == 0 && rld[i].in != 0
+       && ((GET_CODE (in) == REG
+            && GET_RTX_CLASS (GET_CODE (rld[i].in)) == 'a'
+            && MATCHES (XEXP (rld[i].in, 0), in))
+           || (GET_CODE (rld[i].in) == REG
+               && GET_RTX_CLASS (GET_CODE (in)) == 'a'
+               && MATCHES (XEXP (in, 0), rld[i].in)))
+       && (rld[i].out == 0 || ! earlyclobber_operand_p (rld[i].out))
+       && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
+       && MERGABLE_RELOADS (type, rld[i].when_needed,
+                            opnum, rld[i].opnum))
+      {
+       /* Make sure reload_in ultimately has the increment,
+          not the plain register.  */
+       if (GET_CODE (in) == REG)
+         *p_in = rld[i].in;
+       return i;
+      }
+  return n_reloads;
+}
+
+/* Return nonzero if X is a SUBREG which will require reloading of its
+   SUBREG_REG expression.  */
+
+static int
+reload_inner_reg_of_subreg (x, mode)
+     rtx x;
+     enum machine_mode mode;
+{
+  rtx inner;
+
+  /* Only SUBREGs are problematical.  */
+  if (GET_CODE (x) != SUBREG)
+    return 0;
+
+  inner = SUBREG_REG (x);
+
+  /* If INNER is a constant, then INNER must be reloaded.  */
+  if (CONSTANT_P (inner))
+    return 1;
+
+  /* If INNER is not a hard register, then INNER will not need to
+     be reloaded.  */
+  if (GET_CODE (inner) != REG
+      || REGNO (inner) >= FIRST_PSEUDO_REGISTER)
+    return 0;
+
+  /* If INNER is not ok for MODE, then INNER will need reloading.  */
+  if (! HARD_REGNO_MODE_OK (REGNO (inner) + SUBREG_WORD (x), mode))
+    return 1;
+
+  /* If the outer part is a word or smaller, INNER larger than a
+     word and the number of regs for INNER is not the same as the
+     number of words in INNER, then INNER will need reloading.  */
+  return (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
+         && GET_MODE_SIZE (GET_MODE (inner)) > UNITS_PER_WORD
+         && ((GET_MODE_SIZE (GET_MODE (inner)) / UNITS_PER_WORD)
+             != HARD_REGNO_NREGS (REGNO (inner), GET_MODE (inner))));
+}
+
 /* Record one reload that needs to be performed.
    IN is an rtx saying where the data are to be found before this instruction.
    OUT says where they must be stored after the instruction.
@@ -780,7 +839,7 @@ find_valid_class (m1, n)
 static int
 push_reload (in, out, inloc, outloc, class,
             inmode, outmode, strict_low, optional, opnum, type)
-     register rtx in, out;
+     rtx in, out;
      rtx *inloc, *outloc;
      enum reg_class class;
      enum machine_mode inmode, outmode;
@@ -805,7 +864,7 @@ push_reload (in, out, inloc, outloc, class,
   if (outmode == VOIDmode && out != 0)
     outmode = GET_MODE (out);
 
-  /* If IN is a pseudo register everywhere-equivalent to a constant, and 
+  /* If IN is a pseudo register everywhere-equivalent to a constant, and
      it is not in a hard register, reload straight from the constant,
      since we want to get rid of such pseudo registers.
      Often this is done earlier, but not always in find_reloads_address.  */
@@ -835,11 +894,23 @@ push_reload (in, out, inloc, outloc, class,
   if (in != 0 && out != 0 && GET_CODE (in) == MEM && rtx_equal_p (in, out))
     {
       if (GET_CODE (XEXP (in, 0)) == POST_INC
-         || GET_CODE (XEXP (in, 0)) == POST_DEC)
-       in = gen_rtx_MEM (GET_MODE (in), XEXP (XEXP (in, 0), 0));
+         || GET_CODE (XEXP (in, 0)) == POST_DEC
+         || GET_CODE (XEXP (in, 0)) == POST_MODIFY)
+       {
+         rtx new = gen_rtx_MEM (GET_MODE (in), XEXP (XEXP (in, 0), 0));
+
+         MEM_COPY_ATTRIBUTES (new, in);
+         in = new;
+       }
       if (GET_CODE (XEXP (in, 0)) == PRE_INC
-         || GET_CODE (XEXP (in, 0)) == PRE_DEC)
-       out = gen_rtx_MEM (GET_MODE (out), XEXP (XEXP (out, 0), 0));
+         || GET_CODE (XEXP (in, 0)) == PRE_DEC
+         || GET_CODE (XEXP (in, 0)) == PRE_MODIFY)
+       {
+         rtx new = gen_rtx_MEM (GET_MODE (out), XEXP (XEXP (out, 0), 0));
+
+         MEM_COPY_ATTRIBUTES (new, out);
+         out = new;
+       }
     }
 
   /* If we are reloading a (SUBREG constant ...), really reload just the
@@ -869,11 +940,14 @@ push_reload (in, out, inloc, outloc, class,
      the class whose registers cannot be referenced in a different size
      and M1 is not the same size as M2.  If SUBREG_WORD is nonzero, we
      cannot reload just the inside since we might end up with the wrong
-     register class.  */
+     register class.  But if it is inside a STRICT_LOW_PART, we have
+     no choice, so we hope we do get the right register class there.  */
 
-  if (in != 0 && GET_CODE (in) == SUBREG && SUBREG_WORD (in) == 0
-#ifdef CLASS_CANNOT_CHANGE_SIZE
-      && class != CLASS_CANNOT_CHANGE_SIZE
+  if (in != 0 && GET_CODE (in) == SUBREG
+      && (SUBREG_WORD (in) == 0 || strict_low)
+#ifdef CLASS_CANNOT_CHANGE_MODE
+      && (class != CLASS_CANNOT_CHANGE_MODE
+         || ! CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (in)), inmode))
 #endif
       && (CONSTANT_P (SUBREG_REG (in))
          || GET_CODE (SUBREG_REG (in)) == PLUS
@@ -922,14 +996,14 @@ push_reload (in, out, inloc, outloc, class,
                                                SUBREG_REG (in))
                  == NO_REGS))
 #endif
-#ifdef CLASS_CANNOT_CHANGE_SIZE
+#ifdef CLASS_CANNOT_CHANGE_MODE
          || (GET_CODE (SUBREG_REG (in)) == REG
              && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
              && (TEST_HARD_REG_BIT
-                 (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
+                 (reg_class_contents[(int) CLASS_CANNOT_CHANGE_MODE],
                   REGNO (SUBREG_REG (in))))
-             && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
-                 != GET_MODE_SIZE (inmode)))
+             && CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (in)),
+                                            inmode))
 #endif
          ))
     {
@@ -956,20 +1030,7 @@ push_reload (in, out, inloc, outloc, class,
   /* Similar issue for (SUBREG constant ...) if it was not handled by the
      code above.  This can happen if SUBREG_WORD != 0.  */
 
-  if (in != 0 && GET_CODE (in) == SUBREG
-      && (CONSTANT_P (SUBREG_REG (in))
-         || (GET_CODE (SUBREG_REG (in)) == REG
-             && REGNO (SUBREG_REG (in)) < FIRST_PSEUDO_REGISTER
-             && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (in))
-                                       + SUBREG_WORD (in),
-                                       inmode)
-                 || (GET_MODE_SIZE (inmode) <= UNITS_PER_WORD
-                     && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
-                         > UNITS_PER_WORD)
-                     && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (in)))
-                          / UNITS_PER_WORD)
-                         != HARD_REGNO_NREGS (REGNO (SUBREG_REG (in)),
-                                              GET_MODE (SUBREG_REG (in)))))))))
+  if (in != 0 && reload_inner_reg_of_subreg (in, inmode))
     {
       /* This relies on the fact that emit_reload_insns outputs the
         instructions for input reloads of type RELOAD_OTHER in the same
@@ -988,9 +1049,12 @@ push_reload (in, out, inloc, outloc, class,
      storing in a subreg is entitled to clobber it all
      (except in the case of STRICT_LOW_PART,
      and in that case the constraint should label it input-output.)  */
-  if (out != 0 && GET_CODE (out) == SUBREG && SUBREG_WORD (out) == 0
-#ifdef CLASS_CANNOT_CHANGE_SIZE
-      && class != CLASS_CANNOT_CHANGE_SIZE
+  if (out != 0 && GET_CODE (out) == SUBREG
+      && (SUBREG_WORD (out) == 0 || strict_low)
+#ifdef CLASS_CANNOT_CHANGE_MODE
+      && (class != CLASS_CANNOT_CHANGE_MODE
+         || ! CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (out)),
+                                          outmode))
 #endif
       && (CONSTANT_P (SUBREG_REG (out))
          || strict_low
@@ -1006,7 +1070,7 @@ push_reload (in, out, inloc, outloc, class,
                          ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out))) - 1)
                           / UNITS_PER_WORD)))
 #endif
-                 ))
+                 ))
          || (GET_CODE (SUBREG_REG (out)) == REG
              && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
              && ((GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
@@ -1026,22 +1090,22 @@ push_reload (in, out, inloc, outloc, class,
                                                 SUBREG_REG (out))
                  == NO_REGS))
 #endif
-#ifdef CLASS_CANNOT_CHANGE_SIZE
+#ifdef CLASS_CANNOT_CHANGE_MODE
          || (GET_CODE (SUBREG_REG (out)) == REG
              && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
              && (TEST_HARD_REG_BIT
-                 (reg_class_contents[(int) CLASS_CANNOT_CHANGE_SIZE],
+                 (reg_class_contents[(int) CLASS_CANNOT_CHANGE_MODE],
                   REGNO (SUBREG_REG (out))))
-             && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
-                 != GET_MODE_SIZE (outmode)))
+             && CLASS_CANNOT_CHANGE_MODE_P (GET_MODE (SUBREG_REG (out)),
+                                            outmode))
 #endif
          ))
     {
       out_subreg_loc = outloc;
       outloc = &SUBREG_REG (out);
-      out = *outloc; 
+      out = *outloc;
 #if ! defined (LOAD_EXTEND_OP) && ! defined (WORD_REGISTER_OPERATIONS)
-     if (GET_CODE (out) == MEM
+      if (GET_CODE (out) == MEM
          && GET_MODE_SIZE (GET_MODE (out)) > GET_MODE_SIZE (outmode))
        abort ();
 #endif
@@ -1055,18 +1119,7 @@ push_reload (in, out, inloc, outloc, class,
      However, we must reload the inner reg *as well as* the subreg in
      that case.  In this case, the inner reg is an in-out reload.  */
 
-  if (out != 0 && GET_CODE (out) == SUBREG
-      && GET_CODE (SUBREG_REG (out)) == REG
-      && REGNO (SUBREG_REG (out)) < FIRST_PSEUDO_REGISTER
-      && (! HARD_REGNO_MODE_OK (REGNO (SUBREG_REG (out)) + SUBREG_WORD (out),
-                               outmode)
-         || (GET_MODE_SIZE (outmode) <= UNITS_PER_WORD
-             && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
-                 > UNITS_PER_WORD)
-             && ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (out)))
-                  / UNITS_PER_WORD)
-                 != HARD_REGNO_NREGS (REGNO (SUBREG_REG (out)),
-                                      GET_MODE (SUBREG_REG (out)))))))
+  if (out != 0 && reload_inner_reg_of_subreg (out, outmode))
     {
       /* This relies on the fact that emit_reload_insns outputs the
         instructions for output reloads of type RELOAD_OTHER in reverse
@@ -1176,69 +1229,7 @@ push_reload (in, out, inloc, outloc, class,
       && (optional == 0 || type != RELOAD_FOR_OUTPUT))
     abort ();
 
-  /* We can use an existing reload if the class is right
-     and at least one of IN and OUT is a match
-     and the other is at worst neutral.
-     (A zero compared against anything is neutral.) 
-
-     If SMALL_REGISTER_CLASSES, don't use existing reloads unless they are
-     for the same thing since that can cause us to need more reload registers
-     than we otherwise would.  */
-
-  for (i = 0; i < n_reloads; i++)
-    if ((reg_class_subset_p (class, reload_reg_class[i])
-        || reg_class_subset_p (reload_reg_class[i], class))
-       /* If the existing reload has a register, it must fit our class.  */
-       && (reload_reg_rtx[i] == 0
-           || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
-                                 true_regnum (reload_reg_rtx[i])))
-       && ((in != 0 && MATCHES (reload_in[i], in) && ! dont_share
-            && (out == 0 || reload_out[i] == 0 || MATCHES (reload_out[i], out)))
-           ||
-           (out != 0 && MATCHES (reload_out[i], out)
-            && (in == 0 || reload_in[i] == 0 || MATCHES (reload_in[i], in))))
-       && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
-       && MERGABLE_RELOADS (type, reload_when_needed[i],
-                            opnum, reload_opnum[i]))
-      break;
-
-  /* Reloading a plain reg for input can match a reload to postincrement
-     that reg, since the postincrement's value is the right value.
-     Likewise, it can match a preincrement reload, since we regard
-     the preincrementation as happening before any ref in this insn
-     to that register.  */
-  if (i == n_reloads)
-    for (i = 0; i < n_reloads; i++)
-      if ((reg_class_subset_p (class, reload_reg_class[i])
-          || reg_class_subset_p (reload_reg_class[i], class))
-         /* If the existing reload has a register, it must fit our class.  */
-         && (reload_reg_rtx[i] == 0
-             || TEST_HARD_REG_BIT (reg_class_contents[(int) class],
-                                   true_regnum (reload_reg_rtx[i])))
-         && out == 0 && reload_out[i] == 0 && reload_in[i] != 0
-         && ((GET_CODE (in) == REG
-              && (GET_CODE (reload_in[i]) == POST_INC
-                  || GET_CODE (reload_in[i]) == POST_DEC
-                  || GET_CODE (reload_in[i]) == PRE_INC
-                  || GET_CODE (reload_in[i]) == PRE_DEC)
-              && MATCHES (XEXP (reload_in[i], 0), in))
-             ||
-             (GET_CODE (reload_in[i]) == REG
-              && (GET_CODE (in) == POST_INC
-                  || GET_CODE (in) == POST_DEC
-                  || GET_CODE (in) == PRE_INC
-                  || GET_CODE (in) == PRE_DEC)
-              && MATCHES (XEXP (in, 0), reload_in[i])))
-         && (reg_class_size[(int) class] == 1 || SMALL_REGISTER_CLASSES)
-         && MERGABLE_RELOADS (type, reload_when_needed[i],
-                              opnum, reload_opnum[i]))
-       {
-         /* Make sure reload_in ultimately has the increment,
-            not the plain register.  */
-         if (GET_CODE (in) == REG)
-           in = reload_in[i];
-         break;
-       }
+  i = find_reusable_reload (&in, out, class, type, opnum, dont_share);
 
   if (i == n_reloads)
     {
@@ -1268,30 +1259,29 @@ push_reload (in, out, inloc, outloc, class,
       if (in != 0 && GET_CODE (in) == REG
          && REGNO (in) < FIRST_PSEUDO_REGISTER
          && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (REGNO (in)),
-                                    class, inmode))
+                                     class, inmode))
        get_secondary_mem (in, inmode, opnum, type);
 #endif
 
       i = n_reloads;
-      reload_in[i] = in;
-      reload_out[i] = out;
-      reload_reg_class[i] = class;
-      reload_inmode[i] = inmode;
-      reload_outmode[i] = outmode;
-      reload_reg_rtx[i] = 0;
-      reload_optional[i] = optional;
-      reload_nongroup[i] = 0;
-      reload_inc[i] = 0;
-      reload_nocombine[i] = 0;
-      reload_in_reg[i] = inloc ? *inloc : 0;
-      reload_out_reg[i] = outloc ? *outloc : 0;
-      reload_opnum[i] = opnum;
-      reload_when_needed[i] = type;
-      reload_secondary_in_reload[i] = secondary_in_reload;
-      reload_secondary_out_reload[i] = secondary_out_reload;
-      reload_secondary_in_icode[i] = secondary_in_icode;
-      reload_secondary_out_icode[i] = secondary_out_icode;
-      reload_secondary_p[i] = 0;
+      rld[i].in = in;
+      rld[i].out = out;
+      rld[i].class = class;
+      rld[i].inmode = inmode;
+      rld[i].outmode = outmode;
+      rld[i].reg_rtx = 0;
+      rld[i].optional = optional;
+      rld[i].inc = 0;
+      rld[i].nocombine = 0;
+      rld[i].in_reg = inloc ? *inloc : 0;
+      rld[i].out_reg = outloc ? *outloc : 0;
+      rld[i].opnum = opnum;
+      rld[i].when_needed = type;
+      rld[i].secondary_in_reload = secondary_in_reload;
+      rld[i].secondary_out_reload = secondary_out_reload;
+      rld[i].secondary_in_icode = secondary_in_icode;
+      rld[i].secondary_out_icode = secondary_out_icode;
+      rld[i].secondary_p = 0;
 
       n_reloads++;
 
@@ -1313,11 +1303,11 @@ push_reload (in, out, inloc, outloc, class,
       /* The modes can be different.  If they are, we want to reload in
         the larger mode, so that the value is valid for both modes.  */
       if (inmode != VOIDmode
-         && GET_MODE_SIZE (inmode) > GET_MODE_SIZE (reload_inmode[i]))
-       reload_inmode[i] = inmode;
+         && GET_MODE_SIZE (inmode) > GET_MODE_SIZE (rld[i].inmode))
+       rld[i].inmode = inmode;
       if (outmode != VOIDmode
-         && GET_MODE_SIZE (outmode) > GET_MODE_SIZE (reload_outmode[i]))
-       reload_outmode[i] = outmode;
+         && GET_MODE_SIZE (outmode) > GET_MODE_SIZE (rld[i].outmode))
+       rld[i].outmode = outmode;
       if (in != 0)
        {
          rtx in_reg = inloc ? *inloc : 0;
@@ -1325,35 +1315,45 @@ push_reload (in, out, inloc, outloc, class,
             are identical in content, there might be duplicate address
             reloads.  Remove the extra set now, so that if we later find
             that we can inherit this reload, we can get rid of the
-            address reloads altogether.  */
-         if (reload_in[i] != in && rtx_equal_p (in, reload_in[i]))
+            address reloads altogether.
+
+            Do not do this if both reloads are optional since the result
+            would be an optional reload which could potentially leave
+            unresolved address replacements.
+
+            It is not sufficient to call transfer_replacements since
+            choose_reload_regs will remove the replacements for address
+            reloads of inherited reloads which results in the same
+            problem.  */
+         if (rld[i].in != in && rtx_equal_p (in, rld[i].in)
+             && ! (rld[i].optional && optional))
            {
              /* We must keep the address reload with the lower operand
                 number alive.  */
-             if (opnum > reload_opnum[i])
+             if (opnum > rld[i].opnum)
                {
                  remove_address_replacements (in);
-                 in = reload_in[i];
-                 in_reg = reload_in_reg[i];
+                 in = rld[i].in;
+                 in_reg = rld[i].in_reg;
                }
              else
-               remove_address_replacements (reload_in[i]);
+               remove_address_replacements (rld[i].in);
            }
-         reload_in[i] = in;
-         reload_in_reg[i] = in_reg;
+         rld[i].in = in;
+         rld[i].in_reg = in_reg;
        }
       if (out != 0)
        {
-         reload_out[i] = out;
-         reload_out_reg[i] = outloc ? *outloc : 0;
+         rld[i].out = out;
+         rld[i].out_reg = outloc ? *outloc : 0;
        }
-      if (reg_class_subset_p (class, reload_reg_class[i]))
-       reload_reg_class[i] = class;
-      reload_optional[i] &= optional;
-      if (MERGE_TO_OTHER (type, reload_when_needed[i],
-                         opnum, reload_opnum[i]))
-       reload_when_needed[i] = RELOAD_OTHER;
-      reload_opnum[i] = MIN (reload_opnum[i], opnum);
+      if (reg_class_subset_p (class, rld[i].class))
+       rld[i].class = class;
+      rld[i].optional &= optional;
+      if (MERGE_TO_OTHER (type, rld[i].when_needed,
+                         opnum, rld[i].opnum))
+       rld[i].when_needed = RELOAD_OTHER;
+      rld[i].opnum = MIN (rld[i].opnum, opnum);
     }
 
   /* If the ostensible rtx being reload differs from the rtx found
@@ -1361,7 +1361,7 @@ push_reload (in, out, inloc, outloc, class,
      because we cannot reliably tell whether it appears in the insn.  */
 
   if (in != 0 && in != *inloc)
-    reload_nocombine[i] = 1;
+    rld[i].nocombine = 1;
 
 #if 0
   /* This was replaced by changes in find_reloads_address_1 and the new
@@ -1375,12 +1375,12 @@ push_reload (in, out, inloc, outloc, class,
   if (out != 0 && sets_cc0_p (PATTERN (this_insn)))
     {
       out = 0;
-      reload_out[i] = 0;
-      reload_inc[i] = find_inc_amount (PATTERN (this_insn), in);
+      rld[i].out = 0;
+      rld[i].inc = find_inc_amount (PATTERN (this_insn), in);
       /* If we did not find a nonzero amount-to-increment-by,
         that contradicts the belief that IN is being incremented
         in an address in this insn.  */
-      if (reload_inc[i] == 0)
+      if (rld[i].inc == 0)
        abort ();
     }
 #endif
@@ -1414,25 +1414,25 @@ push_reload (in, out, inloc, outloc, class,
      supposed to be made to match, see if either one of the two
      can serve as the place to reload into.
 
-     If one of them is acceptable, set reload_reg_rtx[i]
+     If one of them is acceptable, set rld[i].reg_rtx
      to that one.  */
 
-  if (in != 0 && out != 0 && in != out && reload_reg_rtx[i] == 0)
+  if (in != 0 && out != 0 && in != out && rld[i].reg_rtx == 0)
     {
-      reload_reg_rtx[i] = find_dummy_reload (in, out, inloc, outloc,
-                                            inmode, outmode,
-                                            reload_reg_class[i], i,
-                                            earlyclobber_operand_p (out));
+      rld[i].reg_rtx = find_dummy_reload (in, out, inloc, outloc,
+                                         inmode, outmode,
+                                         rld[i].class, i,
+                                         earlyclobber_operand_p (out));
 
       /* If the outgoing register already contains the same value
         as the incoming one, we can dispense with loading it.
         The easiest way to tell the caller that is to give a phony
         value for the incoming operand (same as outgoing one).  */
-      if (reload_reg_rtx[i] == out
+      if (rld[i].reg_rtx == out
          && (GET_CODE (in) == REG || CONSTANT_P (in))
          && 0 != find_equiv_reg (in, this_insn, 0, REGNO (out),
                                  static_reload_reg_p, i, inmode))
-       reload_in[i] = out;
+       rld[i].in = out;
     }
 
   /* If this is an input reload and the operand contains a register that
@@ -1447,7 +1447,7 @@ push_reload (in, out, inloc, outloc, class,
      But if there is no spilling in this block, that is OK.
      An explicitly used hard reg cannot be a spill reg.  */
 
-  if (reload_reg_rtx[i] == 0 && in != 0)
+  if (rld[i].reg_rtx == 0 && in != 0)
     {
       rtx note;
       int regno;
@@ -1484,12 +1484,23 @@ push_reload (in, out, inloc, outloc, class,
            && GET_MODE_SIZE (inmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
            && HARD_REGNO_MODE_OK (regno, inmode)
            && GET_MODE_SIZE (outmode) <= GET_MODE_SIZE (GET_MODE (XEXP (note, 0)))
-           && HARD_REGNO_MODE_OK (regno, outmode)
-           && TEST_HARD_REG_BIT (reg_class_contents[(int) class], regno)
-           && !fixed_regs[regno])
+           && HARD_REGNO_MODE_OK (regno, outmode))
          {
-           reload_reg_rtx[i] = gen_rtx_REG (inmode, regno);
-           break;
+           unsigned int offs;
+           unsigned int nregs = MAX (HARD_REGNO_NREGS (regno, inmode),
+                                     HARD_REGNO_NREGS (regno, outmode));
+
+           for (offs = 0; offs < nregs; offs++)
+             if (fixed_regs[regno + offs]
+                 || ! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
+                                         regno + offs))
+               break;
+
+           if (offs == nregs)
+             {
+               rld[i].reg_rtx = gen_rtx_REG (inmode, regno);
+               break;
+             }
          }
     }
 
@@ -1547,7 +1558,7 @@ remove_address_replacements (in_rtx)
   char reload_flags[MAX_RELOADS];
   int something_changed = 0;
 
-  bzero (reload_flags, sizeof reload_flags);
+  memset (reload_flags, 0, sizeof reload_flags);
   for (i = 0, j = 0; i < n_replacements; i++)
     {
       if (loc_mentioned_in_p (replacements[i].where, in_rtx))
@@ -1566,39 +1577,13 @@ remove_address_replacements (in_rtx)
       if (reload_flags[i] == 1)
        {
          deallocate_reload_reg (i);
-         remove_address_replacements (reload_in[i]);
-         reload_in[i] = 0;
+         remove_address_replacements (rld[i].in);
+         rld[i].in = 0;
          something_changed = 1;
        }
     }
   return something_changed;
 }
-
-/* Return non-zero if IN contains a piece of rtl that has the address LOC */
-static int
-loc_mentioned_in_p (loc, in)
-     rtx *loc, in;
-{
-  enum rtx_code code = GET_CODE (in);
-  char *fmt = GET_RTX_FORMAT (code);
-  int i, j;
-
-  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
-    {
-      if (loc == &XEXP (in, i))
-       return 1;
-      if (fmt[i] == 'e')
-        {
-         if (loc_mentioned_in_p (loc, XEXP (in, i)))
-           return 1;
-        }
-      else if (fmt[i] == 'E')
-       for (j = XVECLEN (in, i) - 1; i >= 0; i--)
-         if (loc_mentioned_in_p (loc, XVECEXP (in, i, j)))
-           return 1;
-    }
-  return 0;
-}
 \f
 /* If there is only one output reload, and it is not for an earlyclobber
    operand, try to combine it with a (logically unrelated) input reload
@@ -1624,103 +1609,104 @@ combine_reloads ()
      and that one is mandatory.  */
 
   for (i = 0; i < n_reloads; i++)
-    if (reload_out[i] != 0)
+    if (rld[i].out != 0)
       {
        if (output_reload >= 0)
          return;
        output_reload = i;
       }
 
-  if (output_reload < 0 || reload_optional[output_reload])
+  if (output_reload < 0 || rld[output_reload].optional)
     return;
 
   /* An input-output reload isn't combinable.  */
 
-  if (reload_in[output_reload] != 0)
+  if (rld[output_reload].in != 0)
     return;
 
   /* If this reload is for an earlyclobber operand, we can't do anything.  */
-  if (earlyclobber_operand_p (reload_out[output_reload]))
+  if (earlyclobber_operand_p (rld[output_reload].out))
     return;
 
   /* Check each input reload; can we combine it?  */
 
   for (i = 0; i < n_reloads; i++)
-    if (reload_in[i] && ! reload_optional[i] && ! reload_nocombine[i]
+    if (rld[i].in && ! rld[i].optional && ! rld[i].nocombine
        /* Life span of this reload must not extend past main insn.  */
-       && reload_when_needed[i] != RELOAD_FOR_OUTPUT_ADDRESS
-       && reload_when_needed[i] != RELOAD_FOR_OUTADDR_ADDRESS
-       && reload_when_needed[i] != RELOAD_OTHER
-       && (CLASS_MAX_NREGS (reload_reg_class[i], reload_inmode[i])
-           == CLASS_MAX_NREGS (reload_reg_class[output_reload],
-                               reload_outmode[output_reload]))
-       && reload_inc[i] == 0
-       && reload_reg_rtx[i] == 0
+       && rld[i].when_needed != RELOAD_FOR_OUTPUT_ADDRESS
+       && rld[i].when_needed != RELOAD_FOR_OUTADDR_ADDRESS
+       && rld[i].when_needed != RELOAD_OTHER
+       && (CLASS_MAX_NREGS (rld[i].class, rld[i].inmode)
+           == CLASS_MAX_NREGS (rld[output_reload].class,
+                               rld[output_reload].outmode))
+       && rld[i].inc == 0
+       && rld[i].reg_rtx == 0
 #ifdef SECONDARY_MEMORY_NEEDED
        /* Don't combine two reloads with different secondary
           memory locations.  */
-       && (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]] == 0
-           || secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]] == 0
-           || rtx_equal_p (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]],
-                           secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]]))
+       && (secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[i].opnum] == 0
+           || secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum] == 0
+           || rtx_equal_p (secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[i].opnum],
+                           secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum]))
 #endif
        && (SMALL_REGISTER_CLASSES
-           ? (reload_reg_class[i] == reload_reg_class[output_reload])
-           : (reg_class_subset_p (reload_reg_class[i],
-                                  reload_reg_class[output_reload])
-              || reg_class_subset_p (reload_reg_class[output_reload],
-                                     reload_reg_class[i])))
-       && (MATCHES (reload_in[i], reload_out[output_reload])
+           ? (rld[i].class == rld[output_reload].class)
+           : (reg_class_subset_p (rld[i].class,
+                                  rld[output_reload].class)
+              || reg_class_subset_p (rld[output_reload].class,
+                                     rld[i].class)))
+       && (MATCHES (rld[i].in, rld[output_reload].out)
            /* Args reversed because the first arg seems to be
               the one that we imagine being modified
               while the second is the one that might be affected.  */
-           || (! reg_overlap_mentioned_for_reload_p (reload_out[output_reload],
-                                                     reload_in[i])
+           || (! reg_overlap_mentioned_for_reload_p (rld[output_reload].out,
+                                                     rld[i].in)
                /* However, if the input is a register that appears inside
                   the output, then we also can't share.
                   Imagine (set (mem (reg 69)) (plus (reg 69) ...)).
                   If the same reload reg is used for both reg 69 and the
                   result to be stored in memory, then that result
                   will clobber the address of the memory ref.  */
-               && ! (GET_CODE (reload_in[i]) == REG
-                     && reg_overlap_mentioned_for_reload_p (reload_in[i],
-                                                            reload_out[output_reload]))))
-       && (reg_class_size[(int) reload_reg_class[i]]
+               && ! (GET_CODE (rld[i].in) == REG
+                     && reg_overlap_mentioned_for_reload_p (rld[i].in,
+                                                            rld[output_reload].out))))
+       && ! reload_inner_reg_of_subreg (rld[i].in, rld[i].inmode)
+       && (reg_class_size[(int) rld[i].class]
            || SMALL_REGISTER_CLASSES)
        /* We will allow making things slightly worse by combining an
           input and an output, but no worse than that.  */
-       && (reload_when_needed[i] == RELOAD_FOR_INPUT
-           || reload_when_needed[i] == RELOAD_FOR_OUTPUT))
+       && (rld[i].when_needed == RELOAD_FOR_INPUT
+           || rld[i].when_needed == RELOAD_FOR_OUTPUT))
       {
        int j;
 
        /* We have found a reload to combine with!  */
-       reload_out[i] = reload_out[output_reload];
-       reload_out_reg[i] = reload_out_reg[output_reload];
-       reload_outmode[i] = reload_outmode[output_reload];
+       rld[i].out = rld[output_reload].out;
+       rld[i].out_reg = rld[output_reload].out_reg;
+       rld[i].outmode = rld[output_reload].outmode;
        /* Mark the old output reload as inoperative.  */
-       reload_out[output_reload] = 0;
+       rld[output_reload].out = 0;
        /* The combined reload is needed for the entire insn.  */
-       reload_when_needed[i] = RELOAD_OTHER;
+       rld[i].when_needed = RELOAD_OTHER;
        /* If the output reload had a secondary reload, copy it.  */
-       if (reload_secondary_out_reload[output_reload] != -1)
+       if (rld[output_reload].secondary_out_reload != -1)
          {
-           reload_secondary_out_reload[i]
-             = reload_secondary_out_reload[output_reload];
-           reload_secondary_out_icode[i]
-             = reload_secondary_out_icode[output_reload];
+           rld[i].secondary_out_reload
+             = rld[output_reload].secondary_out_reload;
+           rld[i].secondary_out_icode
+             = rld[output_reload].secondary_out_icode;
          }
 
 #ifdef SECONDARY_MEMORY_NEEDED
        /* Copy any secondary MEM.  */
-       if (secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]] != 0)
-         secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[i]]
-           = secondary_memlocs_elim[(int) reload_outmode[output_reload]][reload_opnum[output_reload]];
+       if (secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum] != 0)
+         secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[i].opnum]
+           = secondary_memlocs_elim[(int) rld[output_reload].outmode][rld[output_reload].opnum];
 #endif
        /* If required, minimize the register class.  */
-       if (reg_class_subset_p (reload_reg_class[output_reload],
-                               reload_reg_class[i]))
-         reload_reg_class[i] = reload_reg_class[output_reload];
+       if (reg_class_subset_p (rld[output_reload].class,
+                               rld[i].class))
+         rld[i].class = rld[output_reload].class;
 
        /* Transfer all replacements from the old reload to the combined.  */
        for (j = 0; j < n_replacements; j++)
@@ -1739,9 +1725,9 @@ combine_reloads ()
   if (INSN_CODE (this_insn) == -1)
     return;
 
-  for (i = 1; i < insn_n_operands[INSN_CODE (this_insn)]; i++)
-    if (insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '='
-       || insn_operand_constraint[INSN_CODE (this_insn)][i][0] == '+')
+  for (i = 1; i < insn_data[INSN_CODE (this_insn)].n_operands; i++)
+    if (insn_data[INSN_CODE (this_insn)].operand[i].constraint[0] == '='
+       || insn_data[INSN_CODE (this_insn)].operand[i].constraint[0] == '+')
       return;
 
   /* See if some hard register that dies in this insn and is not used in
@@ -1751,27 +1737,27 @@ combine_reloads ()
     if (REG_NOTE_KIND (note) == REG_DEAD
        && GET_CODE (XEXP (note, 0)) == REG
        && ! reg_overlap_mentioned_for_reload_p (XEXP (note, 0),
-                                                reload_out[output_reload])
+                                                rld[output_reload].out)
        && REGNO (XEXP (note, 0)) < FIRST_PSEUDO_REGISTER
-       && HARD_REGNO_MODE_OK (REGNO (XEXP (note, 0)), reload_outmode[output_reload])
-       && TEST_HARD_REG_BIT (reg_class_contents[(int) reload_reg_class[output_reload]],
+       && HARD_REGNO_MODE_OK (REGNO (XEXP (note, 0)), rld[output_reload].outmode)
+       && TEST_HARD_REG_BIT (reg_class_contents[(int) rld[output_reload].class],
                              REGNO (XEXP (note, 0)))
-       && (HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), reload_outmode[output_reload])
+       && (HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), rld[output_reload].outmode)
            <= HARD_REGNO_NREGS (REGNO (XEXP (note, 0)), GET_MODE (XEXP (note, 0))))
        /* Ensure that a secondary or tertiary reload for this output
           won't want this register.  */
-        && ((secondary_out = reload_secondary_out_reload[output_reload]) == -1
-            || (! (TEST_HARD_REG_BIT
-                   (reg_class_contents[(int) reload_reg_class[secondary_out]],
-                    REGNO (XEXP (note, 0))))
-               && ((secondary_out = reload_secondary_out_reload[secondary_out]) == -1
+       && ((secondary_out = rld[output_reload].secondary_out_reload) == -1
+           || (! (TEST_HARD_REG_BIT
+                  (reg_class_contents[(int) rld[secondary_out].class],
+                   REGNO (XEXP (note, 0))))
+               && ((secondary_out = rld[secondary_out].secondary_out_reload) == -1
                    ||  ! (TEST_HARD_REG_BIT
-                          (reg_class_contents[(int) reload_reg_class[secondary_out]],
+                          (reg_class_contents[(int) rld[secondary_out].class],
                            REGNO (XEXP (note, 0)))))))
        && ! fixed_regs[REGNO (XEXP (note, 0))])
       {
-       reload_reg_rtx[output_reload]
-         = gen_rtx_REG (reload_outmode[output_reload],
+       rld[output_reload].reg_rtx
+         = gen_rtx_REG (rld[output_reload].outmode,
                         REGNO (XEXP (note, 0)));
        return;
       }
@@ -1787,7 +1773,7 @@ combine_reloads ()
 
    If FOR_REAL is >= 0, it is the number of the reload,
    and in some cases when it can be discovered that OUT doesn't need
-   to be computed, clear out reload_out[FOR_REAL].
+   to be computed, clear out rld[FOR_REAL].out.
 
    If FOR_REAL is -1, this should not be done, because this call
    is just to see if a register can be found, not to find and install it.
@@ -1840,8 +1826,8 @@ find_dummy_reload (real_in, real_out, inloc, outloc,
   if (GET_CODE (out) == REG
       && REGNO (out) < FIRST_PSEUDO_REGISTER)
     {
-      register int regno = REGNO (out) + out_offset;
-      int nwords = HARD_REGNO_NREGS (regno, outmode);
+      unsigned int regno = REGNO (out) + out_offset;
+      unsigned int nwords = HARD_REGNO_NREGS (regno, outmode);
       rtx saved_rtx;
 
       /* When we consider whether the insn uses OUT,
@@ -1857,15 +1843,11 @@ find_dummy_reload (real_in, real_out, inloc, outloc,
       *inloc = const0_rtx;
 
       if (regno < FIRST_PSEUDO_REGISTER
-         /* A fixed reg that can overlap other regs better not be used
-            for reloading in any way.  */
-#ifdef OVERLAPPING_REGNO_P
-         && ! (fixed_regs[regno] && OVERLAPPING_REGNO_P (regno))
-#endif
          && ! refers_to_regno_for_reload_p (regno, regno + nwords,
                                             PATTERN (this_insn), outloc))
        {
-         int i;
+         unsigned int i;
+
          for (i = 0; i < nwords; i++)
            if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
                                     regno + i))
@@ -1904,8 +1886,8 @@ find_dummy_reload (real_in, real_out, inloc, outloc,
                             (GET_MODE (out) != VOIDmode
                              ? GET_MODE (out) : outmode)))
     {
-      register int regno = REGNO (in) + in_offset;
-      int nwords = HARD_REGNO_NREGS (regno, inmode);
+      unsigned int regno = REGNO (in) + in_offset;
+      unsigned int nwords = HARD_REGNO_NREGS (regno, inmode);
 
       if (! refers_to_regno_for_reload_p (regno, regno + nwords, out, NULL_PTR)
          && ! hard_reg_set_here_p (regno, regno + nwords,
@@ -1914,7 +1896,8 @@ find_dummy_reload (real_in, real_out, inloc, outloc,
              || ! refers_to_regno_for_reload_p (regno, regno + nwords,
                                                 PATTERN (this_insn), inloc)))
        {
-         int i;
+         unsigned int i;
+
          for (i = 0; i < nwords; i++)
            if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
                                     regno + i))
@@ -1926,7 +1909,7 @@ find_dummy_reload (real_in, real_out, inloc, outloc,
                 and changed our mind, it means OUT is a dummy that
                 dies here.  So don't bother copying value to it.  */
              if (for_real >= 0 && value == real_out)
-               reload_out[for_real] = 0;
+               rld[for_real].out = 0;
              if (GET_CODE (real_in) == REG)
                value = real_in;
              else
@@ -1944,7 +1927,7 @@ find_dummy_reload (real_in, real_out, inloc, outloc,
 
 /* Return 1 if X is an operand of an insn that is being earlyclobbered.  */
 
-static int
+int
 earlyclobber_operand_p (x)
      rtx x;
 {
@@ -1964,17 +1947,19 @@ earlyclobber_operand_p (x)
 
 static int
 hard_reg_set_here_p (beg_regno, end_regno, x)
-     register int beg_regno, end_regno;
+     unsigned int beg_regno, end_regno;
      rtx x;
 {
   if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
     {
       register rtx op0 = SET_DEST (x);
+
       while (GET_CODE (op0) == SUBREG)
        op0 = SUBREG_REG (op0);
       if (GET_CODE (op0) == REG)
        {
-         register int r = REGNO (op0);
+         unsigned int r = REGNO (op0);
+
          /* See if this reg overlaps range under consideration.  */
          if (r < end_regno
              && r + HARD_REGNO_NREGS (r, GET_MODE (op0)) > beg_regno)
@@ -1984,6 +1969,7 @@ hard_reg_set_here_p (beg_regno, end_regno, x)
   else if (GET_CODE (x) == PARALLEL)
     {
       register int i = XVECLEN (x, 0) - 1;
+
       for (; i >= 0; i--)
        if (hard_reg_set_here_p (beg_regno, end_regno, XVECEXP (x, 0, i)))
          return 1;
@@ -1998,7 +1984,7 @@ hard_reg_set_here_p (beg_regno, end_regno, x)
 
 int
 strict_memory_address_p (mode, addr)
-     enum machine_mode mode;
+     enum machine_mode mode ATTRIBUTE_UNUSED;
      register rtx addr;
 {
   GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
@@ -2029,9 +2015,9 @@ operands_match_p (x, y)
 {
   register int i;
   register RTX_CODE code = GET_CODE (x);
-  register char *fmt;
+  register const char *fmt;
   int success_2;
-      
+
   if (x == y)
     return 1;
   if ((code == REG || (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG))
@@ -2077,7 +2063,7 @@ operands_match_p (x, y)
      because the assembler insn would increment only once.
      On the other hand, an postincrement matches ordinary indexing
      if the postincrement is the output operand.  */
-  if (code == POST_DEC || code == POST_INC)
+  if (code == POST_DEC || code == POST_INC || code == POST_MODIFY)
     return operands_match_p (XEXP (x, 0), y);
   /* Two preincrements are invalid
      because the assembler insn would increment only once.
@@ -2085,12 +2071,13 @@ operands_match_p (x, y)
      if the preincrement is the input operand.
      In this case, return 2, since some callers need to do special
      things when this happens.  */
-  if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC)
+  if (GET_CODE (y) == PRE_DEC || GET_CODE (y) == PRE_INC
+      || GET_CODE (y) == PRE_MODIFY)
     return operands_match_p (x, XEXP (y, 0)) ? 2 : 0;
 
  slow:
 
-  /* Now we have disposed of all the cases 
+  /* Now we have disposed of all the cases
      in which different rtx codes can match.  */
   if (code != GET_CODE (y))
     return 0;
@@ -2161,11 +2148,11 @@ operands_match_p (x, y)
 }
 \f
 /* Describe the range of registers or memory referenced by X.
-   If X is a register, set REG_FLAG and put the first register 
+   If X is a register, set REG_FLAG and put the first register
    number into START and the last plus one into END.
-   If X is a memory reference, put a base address into BASE 
+   If X is a memory reference, put a base address into BASE
    and a range of integer offsets into START and END.
-   If X is pushing on the stack, we can assume it causes no trouble, 
+   If X is pushing on the stack, we can assume it causes no trouble,
    so we set the SAFE field.  */
 
 static struct decomposition
@@ -2180,19 +2167,33 @@ decompose (x)
   val.base = 0;
   if (GET_CODE (x) == MEM)
     {
-      rtx base, offset = 0;
+      rtx base = NULL_RTX, offset = 0;
       rtx addr = XEXP (x, 0);
 
       if (GET_CODE (addr) == PRE_DEC || GET_CODE (addr) == PRE_INC
          || GET_CODE (addr) == POST_DEC || GET_CODE (addr) == POST_INC)
        {
          val.base = XEXP (addr, 0);
-         val.start = - GET_MODE_SIZE (GET_MODE (x));
+         val.start = -GET_MODE_SIZE (GET_MODE (x));
          val.end = GET_MODE_SIZE (GET_MODE (x));
          val.safe = REGNO (val.base) == STACK_POINTER_REGNUM;
          return val;
        }
 
+      if (GET_CODE (addr) == PRE_MODIFY || GET_CODE (addr) == POST_MODIFY)
+       {
+         if (GET_CODE (XEXP (addr, 1)) == PLUS
+             && XEXP (addr, 0) == XEXP (XEXP (addr, 1), 0)
+             && CONSTANT_P (XEXP (XEXP (addr, 1), 1)))
+           {
+             val.base  = XEXP (addr, 0);
+             val.start = -INTVAL (XEXP (XEXP (addr, 1), 1));
+             val.end   = INTVAL (XEXP (XEXP (addr, 1), 1));
+             val.safe  = REGNO (val.base) == STACK_POINTER_REGNUM;
+             return val;
+           }
+       }
+
       if (GET_CODE (addr) == CONST)
        {
          addr = XEXP (addr, 0);
@@ -2216,7 +2217,7 @@ decompose (x)
        {
          base = addr;
          offset = const0_rtx;
-       } 
+       }
       if (GET_CODE (offset) == CONST)
        offset = XEXP (offset, 0);
       if (GET_CODE (offset) == PLUS)
@@ -2257,7 +2258,7 @@ decompose (x)
   else if (GET_CODE (x) == REG)
     {
       val.reg_flag = 1;
-      val.start = true_regnum (x); 
+      val.start = true_regnum (x);
       if (val.start < 0)
        {
          /* A pseudo with no hard reg.  */
@@ -2274,7 +2275,7 @@ decompose (x)
        /* This could be more precise, but it's good enough.  */
        return decompose (SUBREG_REG (x));
       val.reg_flag = 1;
-      val.start = true_regnum (x); 
+      val.start = true_regnum (x);
       if (val.start < 0)
        return decompose (SUBREG_REG (x));
       else
@@ -2311,7 +2312,7 @@ immune_p (x, y, ydata)
   if (GET_CODE (x) != MEM)
     return 1;
 
-  xdata =  decompose (x);
+  xdata = decompose (x);
 
   if (! rtx_equal_p (xdata.base, ydata.base))
     {
@@ -2333,7 +2334,6 @@ immune_p (x, y, ydata)
       return 0;
     }
 
-
   return (xdata.start >= ydata.end || ydata.start >= xdata.end);
 }
 
@@ -2378,8 +2378,6 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
      int live_known;
      short *reload_reg_p;
 {
-#ifdef REGISTER_CONSTRAINTS
-
   register int insn_code_number;
   register int i, j;
   int noperands;
@@ -2401,6 +2399,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
   int no_input_reloads = 0, no_output_reloads = 0;
   int n_alternatives;
   int this_alternative[MAX_RECOG_OPERANDS];
+  char this_alternative_match_win[MAX_RECOG_OPERANDS];
   char this_alternative_win[MAX_RECOG_OPERANDS];
   char this_alternative_offmemok[MAX_RECOG_OPERANDS];
   char this_alternative_earlyclobber[MAX_RECOG_OPERANDS];
@@ -2408,27 +2407,24 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
   int swapped;
   int goal_alternative[MAX_RECOG_OPERANDS];
   int this_alternative_number;
-  int goal_alternative_number;
+  int goal_alternative_number = 0;
   int operand_reloadnum[MAX_RECOG_OPERANDS];
   int goal_alternative_matches[MAX_RECOG_OPERANDS];
   int goal_alternative_matched[MAX_RECOG_OPERANDS];
+  char goal_alternative_match_win[MAX_RECOG_OPERANDS];
   char goal_alternative_win[MAX_RECOG_OPERANDS];
   char goal_alternative_offmemok[MAX_RECOG_OPERANDS];
   char goal_alternative_earlyclobber[MAX_RECOG_OPERANDS];
   int goal_alternative_swapped;
   int best;
   int commutative;
-  int changed;
   char operands_match[MAX_RECOG_OPERANDS][MAX_RECOG_OPERANDS];
   rtx substed_operand[MAX_RECOG_OPERANDS];
   rtx body = PATTERN (insn);
   rtx set = single_set (insn);
-  int goal_earlyclobber, this_earlyclobber;
+  int goal_earlyclobber = 0, this_earlyclobber;
   enum machine_mode operand_mode[MAX_RECOG_OPERANDS];
   int retval = 0;
-  /* Cache the last regno for the last pseudo we did an output reload
-     for in case the next insn uses it.  */
-  static int last_output_reload_regno = -1;
 
   this_insn = insn;
   n_reloads = 0;
@@ -2450,12 +2446,12 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
   if (reg_set_p (cc0_rtx, PATTERN (insn)))
     no_output_reloads = 1;
 #endif
-     
+
 #ifdef SECONDARY_MEMORY_NEEDED
   /* The eliminated forms of any secondary memory locations are per-insn, so
      clear them out here.  */
 
-  bzero ((char *) secondary_memlocs_elim, sizeof secondary_memlocs_elim);
+  memset ((char *) secondary_memlocs_elim, 0, sizeof secondary_memlocs_elim);
 #endif
 
   /* Dispose quickly of (set (reg..) (reg..)) if both have hard regs and it
@@ -2472,8 +2468,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
   extract_insn (insn);
 
-  noperands = reload_n_operands = recog_n_operands;
-  n_alternatives = recog_n_alternatives;
+  noperands = reload_n_operands = recog_data.n_operands;
+  n_alternatives = recog_data.n_alternatives;
 
   /* Just return "no reloads" if insn has no operands with constraints.  */
   if (noperands == 0 || n_alternatives == 0)
@@ -2482,10 +2478,9 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
   insn_code_number = INSN_CODE (insn);
   this_insn_is_asm = insn_code_number < 0;
 
-  bcopy ((char *) recog_operand_mode, (char *) operand_mode,
-        noperands * sizeof (enum machine_mode));
-  bcopy ((char *) recog_constraints, (char *) constraints,
-        noperands * sizeof (char *));
+  memcpy (operand_mode, recog_data.operand_mode,
+         noperands * sizeof (enum machine_mode));
+  memcpy (constraints, recog_data.constraints, noperands * sizeof (char *));
 
   commutative = -1;
 
@@ -2499,12 +2494,12 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       register char *p;
       register int c;
 
-      substed_operand[i] = recog_operand[i];
+      substed_operand[i] = recog_data.operand[i];
       p = constraints[i];
 
       modified[i] = RELOAD_READ;
 
-      /* Scan this operand's constraint to see if it is an output operand, 
+      /* Scan this operand's constraint to see if it is an output operand,
         an in-out operand, is commutative, or should match another.  */
 
       while ((c = *p++))
@@ -2525,7 +2520,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
            {
              c -= '0';
              operands_match[c][i]
-               = operands_match_p (recog_operand[c], recog_operand[i]);
+               = operands_match_p (recog_data.operand[c],
+                                   recog_data.operand[i]);
 
              /* An operand may not match itself.  */
              if (c == i)
@@ -2539,13 +2535,15 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                    {
                      int other = c + (c == commutative ? 1 : -1);
                      operands_match[other][i]
-                       = operands_match_p (recog_operand[other], recog_operand[i]);
+                       = operands_match_p (recog_data.operand[other],
+                                           recog_data.operand[i]);
                    }
                  if (i == commutative || i == commutative + 1)
                    {
                      int other = i + (i == commutative ? 1 : -1);
                      operands_match[c][other]
-                       = operands_match_p (recog_operand[c], recog_operand[other]);
+                       = operands_match_p (recog_data.operand[c],
+                                           recog_data.operand[other]);
                    }
                  /* Note that C is supposed to be less than I.
                     No need to consider altering both C and I because in
@@ -2559,13 +2557,13 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
      and reload parts of the addresses into index registers.
      Also here any references to pseudo regs that didn't get hard regs
      but are equivalent to constants get replaced in the insn itself
-     with those constants.  Nobody will ever see them again. 
+     with those constants.  Nobody will ever see them again.
 
      Finally, set up the preferred classes of each operand.  */
 
   for (i = 0; i < noperands; i++)
     {
-      register RTX_CODE code = GET_CODE (recog_operand[i]);
+      register RTX_CODE code = GET_CODE (recog_data.operand[i]);
 
       address_reloaded[i] = 0;
       operand_type[i] = (modified[i] == RELOAD_READ ? RELOAD_FOR_INPUT
@@ -2582,15 +2580,16 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       else if (constraints[i][0] == 'p')
        {
          find_reloads_address (VOIDmode, NULL_PTR,
-                               recog_operand[i], recog_operand_loc[i],
+                               recog_data.operand[i],
+                               recog_data.operand_loc[i],
                                i, operand_type[i], ind_levels, insn);
 
-         /* If we now have a simple operand where we used to have a 
+         /* If we now have a simple operand where we used to have a
             PLUS or MULT, re-recognize and try again.  */
-         if ((GET_RTX_CLASS (GET_CODE (*recog_operand_loc[i])) == 'o'
-              || GET_CODE (*recog_operand_loc[i]) == SUBREG)
-             && (GET_CODE (recog_operand[i]) == MULT
-                 || GET_CODE (recog_operand[i]) == PLUS))
+         if ((GET_RTX_CLASS (GET_CODE (*recog_data.operand_loc[i])) == 'o'
+              || GET_CODE (*recog_data.operand_loc[i]) == SUBREG)
+             && (GET_CODE (recog_data.operand[i]) == MULT
+                 || GET_CODE (recog_data.operand[i]) == PLUS))
            {
              INSN_CODE (insn) = -1;
              retval = find_reloads (insn, replace, ind_levels, live_known,
@@ -2598,51 +2597,55 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
              return retval;
            }
 
-         substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
+         recog_data.operand[i] = *recog_data.operand_loc[i];
+         substed_operand[i] = recog_data.operand[i];
        }
       else if (code == MEM)
        {
-         if (find_reloads_address (GET_MODE (recog_operand[i]),
-                                   recog_operand_loc[i],
-                                   XEXP (recog_operand[i], 0),
-                                   &XEXP (recog_operand[i], 0),
-                                   i, address_type[i], ind_levels, insn))
-           address_reloaded[i] = 1;
-         substed_operand[i] = recog_operand[i] = *recog_operand_loc[i];
+         address_reloaded[i]
+           = find_reloads_address (GET_MODE (recog_data.operand[i]),
+                                   recog_data.operand_loc[i],
+                                   XEXP (recog_data.operand[i], 0),
+                                   &XEXP (recog_data.operand[i], 0),
+                                   i, address_type[i], ind_levels, insn);
+         recog_data.operand[i] = *recog_data.operand_loc[i];
+         substed_operand[i] = recog_data.operand[i];
        }
       else if (code == SUBREG)
        {
-         rtx reg = SUBREG_REG (recog_operand[i]);
+         rtx reg = SUBREG_REG (recog_data.operand[i]);
          rtx op
-           = find_reloads_toplev (recog_operand[i], i, address_type[i],
+           = find_reloads_toplev (recog_data.operand[i], i, address_type[i],
                                   ind_levels,
                                   set != 0
-                                  && &SET_DEST (set) == recog_operand_loc[i],
-                                  insn);
+                                  && &SET_DEST (set) == recog_data.operand_loc[i],
+                                  insn,
+                                  &address_reloaded[i]);
 
          /* If we made a MEM to load (a part of) the stackslot of a pseudo
             that didn't get a hard register, emit a USE with a REG_EQUAL
             note in front so that we might inherit a previous, possibly
             wider reload.  */
-            
+
          if (replace
              && GET_CODE (op) == MEM
              && GET_CODE (reg) == REG
              && (GET_MODE_SIZE (GET_MODE (reg))
                  >= GET_MODE_SIZE (GET_MODE (op))))
-            REG_NOTES (emit_insn_before (gen_rtx_USE (VOIDmode, reg), insn))
-              = gen_rtx_EXPR_LIST (REG_EQUAL,
+           REG_NOTES (emit_insn_before (gen_rtx_USE (VOIDmode, reg), insn))
+             = gen_rtx_EXPR_LIST (REG_EQUAL,
                                   reg_equiv_memory_loc[REGNO (reg)], NULL_RTX);
 
-         substed_operand[i] = recog_operand[i] = op;
+         substed_operand[i] = recog_data.operand[i] = op;
        }
       else if (code == PLUS || GET_RTX_CLASS (code) == '1')
        /* We can get a PLUS as an "operand" as a result of register
           elimination.  See eliminate_regs and gen_reload.  We handle
           a unary operator by reloading the operand.  */
-       substed_operand[i] = recog_operand[i]
-         = find_reloads_toplev (recog_operand[i], i, address_type[i],
-                                ind_levels, 0, insn);
+       substed_operand[i] = recog_data.operand[i]
+         = find_reloads_toplev (recog_data.operand[i], i, address_type[i],
+                                ind_levels, 0, insn,
+                                &address_reloaded[i]);
       else if (code == REG)
        {
          /* This is equivalent to calling find_reloads_toplev.
@@ -2651,42 +2654,46 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
             we replace it by the constant.  We must be sure, however,
             that we don't try to replace it in the insn in which it
             is being set.   */
-         register int regno = REGNO (recog_operand[i]);
+         register int regno = REGNO (recog_data.operand[i]);
          if (reg_equiv_constant[regno] != 0
-             && (set == 0 || &SET_DEST (set) != recog_operand_loc[i]))
+             && (set == 0 || &SET_DEST (set) != recog_data.operand_loc[i]))
            {
              /* Record the existing mode so that the check if constants are
-                allowed will work when operand_mode isn't specified. */
+                allowed will work when operand_mode isn't specified.  */
 
              if (operand_mode[i] == VOIDmode)
-               operand_mode[i] = GET_MODE (recog_operand[i]);
+               operand_mode[i] = GET_MODE (recog_data.operand[i]);
 
-             substed_operand[i] = recog_operand[i]
-               = reg_equiv_constant[regno];
+             substed_operand[i] = recog_data.operand[i]
+               = reg_equiv_constant[regno];
            }
          if (reg_equiv_memory_loc[regno] != 0
              && (reg_equiv_address[regno] != 0 || num_not_at_initial_offset))
            /* We need not give a valid is_set_dest argument since the case
               of a constant equivalence was checked above.  */
-           substed_operand[i] = recog_operand[i]
-             = find_reloads_toplev (recog_operand[i], i, address_type[i],
-                                    ind_levels, 0, insn);
+           substed_operand[i] = recog_data.operand[i]
+             = find_reloads_toplev (recog_data.operand[i], i, address_type[i],
+                                    ind_levels, 0, insn,
+                                    &address_reloaded[i]);
        }
       /* If the operand is still a register (we didn't replace it with an
         equivalent), get the preferred class to reload it into.  */
-      code = GET_CODE (recog_operand[i]);
+      code = GET_CODE (recog_data.operand[i]);
       preferred_class[i]
-       = ((code == REG && REGNO (recog_operand[i]) >= FIRST_PSEUDO_REGISTER)
-          ? reg_preferred_class (REGNO (recog_operand[i])) : NO_REGS);
+       = ((code == REG && REGNO (recog_data.operand[i])
+           >= FIRST_PSEUDO_REGISTER)
+          ? reg_preferred_class (REGNO (recog_data.operand[i]))
+          : NO_REGS);
       pref_or_nothing[i]
-       = (code == REG && REGNO (recog_operand[i]) >= FIRST_PSEUDO_REGISTER
-          && reg_alternate_class (REGNO (recog_operand[i])) == NO_REGS);
+       = (code == REG
+          && REGNO (recog_data.operand[i]) >= FIRST_PSEUDO_REGISTER
+          && reg_alternate_class (REGNO (recog_data.operand[i])) == NO_REGS);
     }
 
   /* If this is simply a copy from operand 1 to operand 0, merge the
      preferred classes for the operands.  */
-  if (set != 0 && noperands >= 2 && recog_operand[0] == SET_DEST (set)
-      && recog_operand[1] == SET_SRC (set))
+  if (set != 0 && noperands >= 2 && recog_data.operand[0] == SET_DEST (set)
+      && recog_data.operand[1] == SET_SRC (set))
     {
       preferred_class[0] = preferred_class[1]
        = reg_class_subunion[(int) preferred_class[0]][(int) preferred_class[1]];
@@ -2725,7 +2732,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       /* REJECT is a count of how undesirable this alternative says it is
         if any reloading is required.  If the alternative matches exactly
         then REJECT is ignored, but otherwise it gets this much
-        counted against it in addition to the reloading needed.  Each 
+        counted against it in addition to the reloading needed.  Each
         ? counts three times here since we want the disparaging caused by
         a bad register class to only count 1/3 as much.  */
       int reject = 0;
@@ -2736,12 +2743,13 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
        {
          register char *p = constraints[i];
          register int win = 0;
+         int did_match = 0;
          /* 0 => this operand can be reloaded somehow for this alternative */
          int badop = 1;
          /* 0 => this operand can be reloaded if the alternative allows regs.  */
          int winreg = 0;
          int c;
-         register rtx operand = recog_operand[i];
+         register rtx operand = recog_data.operand[i];
          int offset = 0;
          /* Nonzero means this is a MEM that must be reloaded into a reg
             regardless of what the constraint says.  */
@@ -2753,7 +2761,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          int earlyclobber = 0;
 
          /* If the predicate accepts a unary operator, it means that
-             we need to reload the operand, but do not do this for
+            we need to reload the operand, but do not do this for
             match_operator and friends.  */
          if (GET_RTX_CLASS (GET_CODE (operand)) == '1' && *p != 0)
            operand = XEXP (operand, 0);
@@ -2783,10 +2791,10 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                     made assumptions about the behavior of the machine in such
                     register access.  If the data is, in fact, in memory we
                     must always load using the size assumed to be in the
-                    register and let the insn do the different-sized 
+                    register and let the insn do the different-sized
                     accesses.
 
-                    This is doubly true if WORD_REGISTER_OPERATIONS.  In 
+                    This is doubly true if WORD_REGISTER_OPERATIONS.  In
                     this case eliminate_regs has left non-paradoxical
                     subregs for push_reloads to see.  Make sure it does
                     by forcing the reload.
@@ -2834,6 +2842,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
          this_alternative[i] = (int) NO_REGS;
          this_alternative_win[i] = 0;
+         this_alternative_match_win[i] = 0;
          this_alternative_offmemok[i] = 0;
          this_alternative_earlyclobber[i] = 0;
          this_alternative_matches[i] = -1;
@@ -2853,9 +2862,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          while (*p && (c = *p++) != ',')
            switch (c)
              {
-             case '=':
-             case '+':
-             case '*':
+             case '=':  case '+':  case '*':
                break;
 
              case '%':
@@ -2875,14 +2882,13 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
              case '#':
                /* Ignore rest of this alternative as far as
                   reloading is concerned.  */
-               while (*p && *p != ',') p++;
+               while (*p && *p != ',')
+                 p++;
                break;
 
-             case '0':
-             case '1':
-             case '2':
-             case '3':
-             case '4':
+             case '0':  case '1':  case '2':  case '3':  case '4':
+             case '5':  case '6':  case '7':  case '8':  case '9':
+
                c -= '0';
                this_alternative_matches[i] = c;
                /* We are supposed to match a previous operand.
@@ -2900,22 +2906,22 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                       don't exchange them, because operands_match is valid
                       only on one side of its diagonal.  */
                    ? (operands_match
-                       [(c == commutative || c == commutative + 1)
-                        ? 2*commutative + 1 - c : c]
-                       [(i == commutative || i == commutative + 1)
-                        ? 2*commutative + 1 - i : i])
+                      [(c == commutative || c == commutative + 1)
+                      ? 2 * commutative + 1 - c : c]
+                      [(i == commutative || i == commutative + 1)
+                      ? 2 * commutative + 1 - i : i])
                    : operands_match[c][i])
                  {
                    /* If we are matching a non-offsettable address where an
                       offsettable address was expected, then we must reject
                       this combination, because we can't reload it.  */
                    if (this_alternative_offmemok[c]
-                       && GET_CODE (recog_operand[c]) == MEM
+                       && GET_CODE (recog_data.operand[c]) == MEM
                        && this_alternative[c] == (int) NO_REGS
                        && ! this_alternative_win[c])
                      bad = 1;
 
-                   win = this_alternative_win[c];
+                   did_match = this_alternative_win[c];
                  }
                else
                  {
@@ -2931,8 +2937,10 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                    /* But count the pair only once in the total badness of
                       this alternative, if the pair can be a dummy reload.  */
                    value
-                     = find_dummy_reload (recog_operand[i], recog_operand[c],
-                                          recog_operand_loc[i], recog_operand_loc[c],
+                     = find_dummy_reload (recog_data.operand[i],
+                                          recog_data.operand[c],
+                                          recog_data.operand_loc[i],
+                                          recog_data.operand_loc[c],
                                           operand_mode[i], operand_mode[c],
                                           this_alternative[c], -1,
                                           this_alternative_earlyclobber[c]);
@@ -2949,12 +2957,11 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                   operand also had to match the same thing as this
                   operand, we don't know how to do that.  So reject this
                   alternative.  */
-               if (! win || force_reload)
+               if (! did_match || force_reload)
                  for (j = 0; j < i; j++)
                    if (this_alternative_matches[j]
                        == this_alternative_matches[i])
                      badop = 1;
-
                break;
 
              case 'p':
@@ -3020,24 +3027,11 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                     /* If IND_LEVELS, find_reloads_address won't reload a
                        pseudo that didn't get a hard reg, so we have to
                        reject that case.  */
-                    && (ind_levels ? offsettable_memref_p (operand)
-                        : offsettable_nonstrict_memref_p (operand)))
-                   /* A reloaded auto-increment address is offsettable,
-                      because it is now just a simple register indirect.  */
-                   || (GET_CODE (operand) == MEM
-                       && address_reloaded[i]
-                       && (GET_CODE (XEXP (operand, 0)) == PRE_INC
-                           || GET_CODE (XEXP (operand, 0)) == PRE_DEC
-                           || GET_CODE (XEXP (operand, 0)) == POST_INC
-                           || GET_CODE (XEXP (operand, 0)) == POST_DEC))
-                   /* Certain mem addresses will become offsettable
-                      after they themselves are reloaded.  This is important;
-                      we don't want our own handling of unoffsettables
-                      to override the handling of reg_equiv_address.  */
-                   || (GET_CODE (operand) == MEM
-                       && GET_CODE (XEXP (operand, 0)) == REG
-                       && (ind_levels == 0
-                           || reg_equiv_address[REGNO (XEXP (operand, 0))] != 0))
+                    && ((ind_levels ? offsettable_memref_p (operand)
+                         : offsettable_nonstrict_memref_p (operand))
+                        /* A reloaded address is offsettable because it is now
+                           just a simple register indirect.  */
+                        || address_reloaded[i]))
                    || (GET_CODE (operand) == REG
                        && REGNO (operand) >= FIRST_PSEUDO_REGISTER
                        && reg_renumber[REGNO (operand)] < 0
@@ -3134,8 +3128,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                    /* A SCRATCH is not a valid operand.  */
                    && GET_CODE (operand) != SCRATCH
 #ifdef LEGITIMATE_PIC_OPERAND_P
-                   && (! CONSTANT_P (operand) 
-                       || ! flag_pic 
+                   && (! CONSTANT_P (operand)
+                       || ! flag_pic
                        || LEGITIMATE_PIC_OPERAND_P (operand))
 #endif
                    && (GENERAL_REGS == ALL_REGS
@@ -3150,28 +3144,25 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                  = (int) reg_class_subunion[this_alternative[i]][(int) GENERAL_REGS];
                goto reg;
 
+             default:
+               if (REG_CLASS_FROM_LETTER (c) == NO_REGS)
+                 {
 #ifdef EXTRA_CONSTRAINT
-              case 'Q':
-              case 'R':
-              case 'S':
-              case 'T':
-              case 'U':
-               if (EXTRA_CONSTRAINT (operand, c))
-                 win = 1;
-               break;
+                   if (EXTRA_CONSTRAINT (operand, c))
+                     win = 1;
 #endif
-  
-             default:
+                   break;
+                 }
+
                this_alternative[i]
                  = (int) reg_class_subunion[this_alternative[i]][(int) REG_CLASS_FROM_LETTER (c)];
-               
              reg:
                if (GET_MODE (operand) == BLKmode)
                  break;
                winreg = 1;
                if (GET_CODE (operand) == REG
                    && reg_fits_class_p (operand, this_alternative[i],
-                                        offset, GET_MODE (recog_operand[i])))
+                                        offset, GET_MODE (recog_data.operand[i])))
                  win = 1;
                break;
              }
@@ -3187,6 +3178,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          this_alternative_earlyclobber[i] = earlyclobber;
          if (win && ! force_reload)
            this_alternative_win[i] = 1;
+         else if (did_match && ! force_reload)
+           this_alternative_match_win[i] = 1;
          else
            {
              int const_to_mem = 0;
@@ -3201,34 +3194,19 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                  && this_alternative_matches[i] < 0)
                bad = 1;
 
-#if 0
-             /* If this is a pseudo-register that is set in the previous
-                insns, there's a good chance that it will already be in a
-                spill register and we can use that spill register.  So
-                make this case cheaper. 
-
-                Disabled for egcs.  egcs has better inheritance code and
-                this change causes problems with the improved reload
-                inheritance code.  */
-             if (GET_CODE (operand) == REG
-                 && REGNO (operand) >= FIRST_PSEUDO_REGISTER
-                 && REGNO (operand) == last_output_reload_regno)
-               reject--;
-#endif
-
              /* If this is a constant that is reloaded into the desired
                 class by copying it to memory first, count that as another
                 reload.  This is consistent with other code and is
                 required to avoid choosing another alternative when
                 the constant is moved into memory by this function on
-                an early reload pass.  Note that the test here is 
+                an early reload pass.  Note that the test here is
                 precisely the same as in the code below that calls
                 force_const_mem.  */
              if (CONSTANT_P (operand)
                  /* force_const_mem does not accept HIGH.  */
                  && GET_CODE (operand) != HIGH
                  && ((PREFERRED_RELOAD_CLASS (operand,
-                                             (enum reg_class) this_alternative[i])
+                                              (enum reg_class) this_alternative[i])
                       == NO_REGS)
                      || no_input_reloads)
                  && operand_mode[i] != VOIDmode)
@@ -3254,18 +3232,17 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                 permitted for this insn.  We can always reload SCRATCH
                 and objects with a REG_UNUSED note.  */
              else if (GET_CODE (operand) != SCRATCH
-                 && modified[i] != RELOAD_READ && no_output_reloads
-                 && ! find_reg_note (insn, REG_UNUSED, operand))
+                      && modified[i] != RELOAD_READ && no_output_reloads
+                      && ! find_reg_note (insn, REG_UNUSED, operand))
                bad = 1;
              else if (modified[i] != RELOAD_WRITE && no_input_reloads
                       && ! const_to_mem)
                bad = 1;
 
-
              /* We prefer to reload pseudos over reloading other things,
                 since such reloads may be able to be eliminated later.
                 If we are reloading a SCRATCH, we won't be generating any
-                insns, just using a register, so it is also preferred. 
+                insns, just using a register, so it is also preferred.
                 So bump REJECT in other cases.  Don't do this in the
                 case where we are forcing a constant into memory and
                 it will then win since we don't want to have a different
@@ -3283,7 +3260,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                reject++;
            }
 
-         /* If this operand is a pseudo register that didn't get a hard 
+         /* If this operand is a pseudo register that didn't get a hard
             reg and this alternative accepts some register, see if the
             class that we want is a subset of the preferred class for this
             register.  If not, but it intersects that class, use the
@@ -3304,8 +3281,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
             Don't do this if the preferred class has only one register
             because we might otherwise exhaust the class.  */
 
-
-         if (! win && this_alternative[i] != (int) NO_REGS
+         if (! win && ! did_match
+             && this_alternative[i] != (int) NO_REGS
              && GET_MODE_SIZE (operand_mode[i]) <= UNITS_PER_WORD
              && reg_class_size[(int) preferred_class[i]] > 1)
            {
@@ -3314,7 +3291,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                {
                  /* Since we don't have a way of forming the intersection,
                     we just do something special if the preferred class
-                    is a subset of the class we have; that's the most 
+                    is a subset of the class we have; that's the most
                     common case anyway.  */
                  if (reg_class_subset_p (preferred_class[i],
                                          this_alternative[i]))
@@ -3331,15 +3308,15 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
       for (i = 0; i < noperands; i++)
        if (this_alternative_earlyclobber[i]
-           && this_alternative_win[i])
+           && (this_alternative_win[i] || this_alternative_match_win[i]))
          {
-           struct decomposition early_data; 
+           struct decomposition early_data;
 
-           early_data = decompose (recog_operand[i]);
+           early_data = decompose (recog_data.operand[i]);
 
            if (modified[i] == RELOAD_READ)
              abort ();
-           
+
            if (this_alternative[i] == NO_REGS)
              {
                this_alternative_earlyclobber[i] = 0;
@@ -3352,26 +3329,29 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
            for (j = 0; j < noperands; j++)
              /* Is this an input operand or a memory ref?  */
-             if ((GET_CODE (recog_operand[j]) == MEM
+             if ((GET_CODE (recog_data.operand[j]) == MEM
                   || modified[j] != RELOAD_WRITE)
                  && j != i
                  /* Ignore things like match_operator operands.  */
-                 && *recog_constraints[j] != 0
+                 && *recog_data.constraints[j] != 0
                  /* Don't count an input operand that is constrained to match
                     the early clobber operand.  */
                  && ! (this_alternative_matches[j] == i
-                       && rtx_equal_p (recog_operand[i], recog_operand[j]))
+                       && rtx_equal_p (recog_data.operand[i],
+                                       recog_data.operand[j]))
                  /* Is it altered by storing the earlyclobber operand?  */
-                 && !immune_p (recog_operand[j], recog_operand[i], early_data))
+                 && !immune_p (recog_data.operand[j], recog_data.operand[i],
+                               early_data))
                {
                  /* If the output is in a single-reg class,
                     it's costly to reload it, so reload the input instead.  */
                  if (reg_class_size[this_alternative[i]] == 1
-                     && (GET_CODE (recog_operand[j]) == REG
-                         || GET_CODE (recog_operand[j]) == SUBREG))
+                     && (GET_CODE (recog_data.operand[j]) == REG
+                         || GET_CODE (recog_data.operand[j]) == SUBREG))
                    {
                      losers++;
                      this_alternative_win[j] = 0;
+                     this_alternative_match_win[j] = 0;
                    }
                  else
                    break;
@@ -3382,11 +3362,13 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
              {
                losers++;
                this_alternative_win[i] = 0;
+               this_alternative_match_win[j] = 0;
                for (j = 0; j < noperands; j++)
                  if (this_alternative_matches[j] == i
-                     && this_alternative_win[j])
+                     && this_alternative_match_win[j])
                    {
                      this_alternative_win[j] = 0;
+                     this_alternative_match_win[j] = 0;
                      losers++;
                    }
              }
@@ -3399,13 +3381,14 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          /* Unswap these so that they are never swapped at `finish'.  */
          if (commutative >= 0)
            {
-             recog_operand[commutative] = substed_operand[commutative];
-             recog_operand[commutative + 1]
+             recog_data.operand[commutative] = substed_operand[commutative];
+             recog_data.operand[commutative + 1]
                = substed_operand[commutative + 1];
            }
          for (i = 0; i < noperands; i++)
            {
-             goal_alternative_win[i] = 1;
+             goal_alternative_win[i] = this_alternative_win[i];
+             goal_alternative_match_win[i] = this_alternative_match_win[i];
              goal_alternative[i] = this_alternative[i];
              goal_alternative_offmemok[i] = this_alternative_offmemok[i];
              goal_alternative_matches[i] = this_alternative_matches[i];
@@ -3433,6 +3416,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
            {
              goal_alternative[i] = this_alternative[i];
              goal_alternative_win[i] = this_alternative_win[i];
+             goal_alternative_match_win[i] = this_alternative_match_win[i];
              goal_alternative_offmemok[i] = this_alternative_offmemok[i];
              goal_alternative_matches[i] = this_alternative_matches[i];
              goal_alternative_earlyclobber[i]
@@ -3462,8 +3446,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          register enum reg_class tclass;
          register int t;
 
-         recog_operand[commutative] = substed_operand[commutative + 1];
-         recog_operand[commutative + 1] = substed_operand[commutative];
+         recog_data.operand[commutative] = substed_operand[commutative + 1];
+         recog_data.operand[commutative + 1] = substed_operand[commutative];
 
          tclass = preferred_class[commutative];
          preferred_class[commutative] = preferred_class[commutative + 1];
@@ -3473,14 +3457,15 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          pref_or_nothing[commutative] = pref_or_nothing[commutative + 1];
          pref_or_nothing[commutative + 1] = t;
 
-         bcopy ((char *) recog_constraints, (char *) constraints,
-                noperands * sizeof (char *));
+         memcpy (constraints, recog_data.constraints,
+                 noperands * sizeof (char *));
          goto try_swapped;
        }
       else
        {
-         recog_operand[commutative] = substed_operand[commutative];
-         recog_operand[commutative + 1] = substed_operand[commutative + 1];
+         recog_data.operand[commutative] = substed_operand[commutative];
+         recog_data.operand[commutative + 1]
+           = substed_operand[commutative + 1];
        }
     }
 
@@ -3493,7 +3478,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
     {
       /* No alternative works with reloads??  */
       if (insn_code_number >= 0)
-       abort ();
+       fatal_insn ("Unable to generate reloads for:", insn);
       error_for_asm (insn, "inconsistent operand constraints in an `asm'");
       /* Avoid further trouble with this insn.  */
       PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx);
@@ -3513,12 +3498,15 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
   for (i = 0; i < noperands; i++)
     goal_alternative_matched[i] = -1;
-
   for (i = 0; i < noperands; i++)
     if (! goal_alternative_win[i]
        && goal_alternative_matches[i] >= 0)
       goal_alternative_matched[goal_alternative_matches[i]] = i;
 
+  for (i = 0; i < noperands; i++)
+    goal_alternative_win[i] |= goal_alternative_match_win[i];
+
   /* If the best alternative is with operands 1 and 2 swapped,
      consider them swapped before reporting the reloads.  Update the
      operand numbers of any reloads already pushed.  */
@@ -3530,19 +3518,20 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       tem = substed_operand[commutative];
       substed_operand[commutative] = substed_operand[commutative + 1];
       substed_operand[commutative + 1] = tem;
-      tem = recog_operand[commutative];
-      recog_operand[commutative] = recog_operand[commutative + 1];
-      recog_operand[commutative + 1] = tem;
-      tem = *recog_operand_loc[commutative];
-      *recog_operand_loc[commutative] = *recog_operand_loc[commutative+1];
-      *recog_operand_loc[commutative+1] = tem;
+      tem = recog_data.operand[commutative];
+      recog_data.operand[commutative] = recog_data.operand[commutative + 1];
+      recog_data.operand[commutative + 1] = tem;
+      tem = *recog_data.operand_loc[commutative];
+      *recog_data.operand_loc[commutative]
+       = *recog_data.operand_loc[commutative + 1];
+      *recog_data.operand_loc[commutative + 1] = tem;
 
       for (i = 0; i < n_reloads; i++)
        {
-         if (reload_opnum[i] == commutative)
-           reload_opnum[i] = commutative + 1;
-         else if (reload_opnum[i] == commutative + 1)
-           reload_opnum[i] = commutative;
+         if (rld[i].opnum == commutative)
+           rld[i].opnum = commutative + 1;
+         else if (rld[i].opnum == commutative + 1)
+           rld[i].opnum = commutative;
        }
     }
 
@@ -3558,9 +3547,9 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
         One special case that is worth checking is when we have an
         output that is earlyclobber but isn't used past the insn (typically
-        a SCRATCH).  In this case, we only need have the reload live 
+        a SCRATCH).  In this case, we only need have the reload live
         through the insn itself, but not for any of our input or output
-        reloads. 
+        reloads.
         But we must not accidentally narrow the scope of an existing
         RELOAD_OTHER reload - leave these alone.
 
@@ -3569,7 +3558,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
       if (goal_alternative_earlyclobber[i] && operand_type[i] != RELOAD_OTHER)
        operand_type[i]
-         = (find_reg_note (insn, REG_UNUSED, recog_operand[i])
+         = (find_reg_note (insn, REG_UNUSED, recog_data.operand[i])
             ? RELOAD_FOR_INSN : RELOAD_OTHER);
     }
 
@@ -3577,20 +3566,21 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
      into registers are here changed into memory references.  */
   for (i = 0; i < noperands; i++)
     if (! goal_alternative_win[i]
-       && CONSTANT_P (recog_operand[i])
+       && CONSTANT_P (recog_data.operand[i])
        /* force_const_mem does not accept HIGH.  */
-       && GET_CODE (recog_operand[i]) != HIGH
-       && ((PREFERRED_RELOAD_CLASS (recog_operand[i],
-                                   (enum reg_class) goal_alternative[i])
+       && GET_CODE (recog_data.operand[i]) != HIGH
+       && ((PREFERRED_RELOAD_CLASS (recog_data.operand[i],
+                                    (enum reg_class) goal_alternative[i])
             == NO_REGS)
            || no_input_reloads)
        && operand_mode[i] != VOIDmode)
       {
-       substed_operand[i] = recog_operand[i]
+       substed_operand[i] = recog_data.operand[i]
          = find_reloads_toplev (force_const_mem (operand_mode[i],
-                                                 recog_operand[i]),
-                                i, address_type[i], ind_levels, 0, insn);
-       if (alternative_allows_memconst (recog_constraints[i],
+                                                 recog_data.operand[i]),
+                                i, address_type[i], ind_levels, 0, insn,
+                                NULL);
+       if (alternative_allows_memconst (recog_data.constraints[i],
                                         goal_alternative_number))
          goal_alternative_win[i] = 1;
       }
@@ -3599,10 +3589,9 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
   if (goal_earlyclobber)
     for (i = 0; i < noperands; i++)
       if (goal_alternative_earlyclobber[i])
-       reload_earlyclobbers[n_earlyclobbers++] = recog_operand[i];
+       reload_earlyclobbers[n_earlyclobbers++] = recog_data.operand[i];
 
   /* Now record reloads for all the operands that need them.  */
-  last_output_reload_regno = -1;
   for (i = 0; i < noperands; i++)
     if (! goal_alternative_win[i])
       {
@@ -3618,15 +3607,16 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
           so we don't bother with it.  It may not be worth doing.  */
        else if (goal_alternative_matched[i] == -1
                 && goal_alternative_offmemok[i]
-                && GET_CODE (recog_operand[i]) == MEM)
+                && GET_CODE (recog_data.operand[i]) == MEM)
          {
            operand_reloadnum[i]
-             = push_reload (XEXP (recog_operand[i], 0), NULL_RTX,
-                            &XEXP (recog_operand[i], 0), NULL_PTR,
-                            BASE_REG_CLASS, GET_MODE (XEXP (recog_operand[i], 0)),
+             = push_reload (XEXP (recog_data.operand[i], 0), NULL_RTX,
+                            &XEXP (recog_data.operand[i], 0), NULL_PTR,
+                            BASE_REG_CLASS,
+                            GET_MODE (XEXP (recog_data.operand[i], 0)),
                             VOIDmode, 0, 0, i, RELOAD_FOR_INPUT);
-           reload_inc[operand_reloadnum[i]]
-             = GET_MODE_SIZE (GET_MODE (recog_operand[i]));
+           rld[operand_reloadnum[i]].inc
+             = GET_MODE_SIZE (GET_MODE (recog_data.operand[i]));
 
            /* If this operand is an output, we will have made any
               reloads for its address as RELOAD_FOR_OUTPUT_ADDRESS, but
@@ -3637,13 +3627,13 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
              {
                for (j = 0; j < n_reloads; j++)
                  {
-                   if (reload_opnum[j] == i)
+                   if (rld[j].opnum == i)
                      {
-                       if (reload_when_needed[j] == RELOAD_FOR_OUTPUT_ADDRESS)
-                         reload_when_needed[j] = RELOAD_FOR_INPUT_ADDRESS;
-                       else if (reload_when_needed[j]
+                       if (rld[j].when_needed == RELOAD_FOR_OUTPUT_ADDRESS)
+                         rld[j].when_needed = RELOAD_FOR_INPUT_ADDRESS;
+                       else if (rld[j].when_needed
                                 == RELOAD_FOR_OUTADDR_ADDRESS)
-                         reload_when_needed[j] = RELOAD_FOR_INPADDR_ADDRESS;
+                         rld[j].when_needed = RELOAD_FOR_INPADDR_ADDRESS;
                      }
                  }
              }
@@ -3652,23 +3642,21 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
          {
            operand_reloadnum[i]
              = push_reload ((modified[i] != RELOAD_WRITE
-                             ? recog_operand[i] : 0),
-                            modified[i] != RELOAD_READ ? recog_operand[i] : 0,
+                             ? recog_data.operand[i] : 0),
+                            (modified[i] != RELOAD_READ
+                             ? recog_data.operand[i] : 0),
                             (modified[i] != RELOAD_WRITE
-                             ? recog_operand_loc[i] : 0),
+                             ? recog_data.operand_loc[i] : 0),
                             (modified[i] != RELOAD_READ
-                             ? recog_operand_loc[i] : 0),
+                             ? recog_data.operand_loc[i] : 0),
                             (enum reg_class) goal_alternative[i],
                             (modified[i] == RELOAD_WRITE
                              ? VOIDmode : operand_mode[i]),
                             (modified[i] == RELOAD_READ
                              ? VOIDmode : operand_mode[i]),
                             (insn_code_number < 0 ? 0
-                             : insn_operand_strict_low[insn_code_number][i]),
+                             : insn_data[insn_code_number].operand[i].strict_low),
                             0, i, operand_type[i]);
-           if (modified[i] != RELOAD_READ
-               && GET_CODE (recog_operand[i]) == REG)
-             last_output_reload_regno = REGNO (recog_operand[i]);
          }
        /* In a matching pair of operands, one must be input only
           and the other must be output only.
@@ -3677,34 +3665,29 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
                 && modified[goal_alternative_matched[i]] == RELOAD_WRITE)
          {
            operand_reloadnum[i]
-             = push_reload (recog_operand[i],
-                            recog_operand[goal_alternative_matched[i]],
-                            recog_operand_loc[i],
-                            recog_operand_loc[goal_alternative_matched[i]],
+             = push_reload (recog_data.operand[i],
+                            recog_data.operand[goal_alternative_matched[i]],
+                            recog_data.operand_loc[i],
+                            recog_data.operand_loc[goal_alternative_matched[i]],
                             (enum reg_class) goal_alternative[i],
                             operand_mode[i],
                             operand_mode[goal_alternative_matched[i]],
                             0, 0, i, RELOAD_OTHER);
            operand_reloadnum[goal_alternative_matched[i]] = output_reloadnum;
-           if (GET_CODE (recog_operand[goal_alternative_matched[i]]) == REG)
-             last_output_reload_regno
-               = REGNO (recog_operand[goal_alternative_matched[i]]);
          }
        else if (modified[i] == RELOAD_WRITE
                 && modified[goal_alternative_matched[i]] == RELOAD_READ)
          {
            operand_reloadnum[goal_alternative_matched[i]]
-             = push_reload (recog_operand[goal_alternative_matched[i]],
-                            recog_operand[i],
-                            recog_operand_loc[goal_alternative_matched[i]],
-                            recog_operand_loc[i],
+             = push_reload (recog_data.operand[goal_alternative_matched[i]],
+                            recog_data.operand[i],
+                            recog_data.operand_loc[goal_alternative_matched[i]],
+                            recog_data.operand_loc[i],
                             (enum reg_class) goal_alternative[i],
                             operand_mode[goal_alternative_matched[i]],
                             operand_mode[i],
                             0, 0, i, RELOAD_OTHER);
            operand_reloadnum[i] = output_reloadnum;
-           if (GET_CODE (recog_operand[i]) == REG)
-             last_output_reload_regno = REGNO (recog_operand[i]);
          }
        else if (insn_code_number >= 0)
          abort ();
@@ -3721,11 +3704,11 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
             && goal_alternative_matches[i] < 0
             && optimize)
       {
-       /* For each non-matching operand that's a MEM or a pseudo-register 
+       /* For each non-matching operand that's a MEM or a pseudo-register
           that didn't get a hard register, make an optional reload.
           This may get done even if the insn needs no reloads otherwise.  */
 
-       rtx operand = recog_operand[i];
+       rtx operand = recog_data.operand[i];
 
        while (GET_CODE (operand) == SUBREG)
          operand = XEXP (operand, 0);
@@ -3748,27 +3731,34 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
            && (modified[i] == RELOAD_READ
                || (! no_output_reloads && ! this_insn_is_asm)))
          operand_reloadnum[i]
-           = push_reload (modified[i] != RELOAD_WRITE ? recog_operand[i] : 0,
-                          modified[i] != RELOAD_READ ? recog_operand[i] : 0,
+           = push_reload ((modified[i] != RELOAD_WRITE
+                           ? recog_data.operand[i] : 0),
+                          (modified[i] != RELOAD_READ
+                           ? recog_data.operand[i] : 0),
                           (modified[i] != RELOAD_WRITE
-                           ? recog_operand_loc[i] : 0),
+                           ? recog_data.operand_loc[i] : 0),
                           (modified[i] != RELOAD_READ
-                           ? recog_operand_loc[i] : 0),
+                           ? recog_data.operand_loc[i] : 0),
                           (enum reg_class) goal_alternative[i],
                           (modified[i] == RELOAD_WRITE
                            ? VOIDmode : operand_mode[i]),
                           (modified[i] == RELOAD_READ
                            ? VOIDmode : operand_mode[i]),
                           (insn_code_number < 0 ? 0
-                           : insn_operand_strict_low[insn_code_number][i]),
+                           : insn_data[insn_code_number].operand[i].strict_low),
                           1, i, operand_type[i]);
-       /* If a memory reference remains, yet we can't make an optional
+       /* If a memory reference remains (either as a MEM or a pseudo that
+          did not get a hard register), yet we can't make an optional
           reload, check if this is actually a pseudo register reference;
           we then need to emit a USE and/or a CLOBBER so that reload
           inheritance will do the right thing.  */
-       else if (replace && GET_CODE (operand) == MEM)
+       else if (replace
+                && (GET_CODE (operand) == MEM
+                    || (GET_CODE (operand) == REG
+                        && REGNO (operand) >= FIRST_PSEUDO_REGISTER
+                        && reg_renumber [REGNO (operand)] < 0)))
          {
-           operand = *recog_operand_loc[i];
+           operand = *recog_data.operand_loc[i];
 
            while (GET_CODE (operand) == SUBREG)
              operand = XEXP (operand, 0);
@@ -3791,7 +3781,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
        /* Similarly, make an optional reload for a pair of matching
           objects that are in MEM or a pseudo that didn't get a hard reg.  */
 
-       rtx operand = recog_operand[i];
+       rtx operand = recog_data.operand[i];
 
        while (GET_CODE (operand) == SUBREG)
          operand = XEXP (operand, 0);
@@ -3801,16 +3791,16 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
            && ((enum reg_class) goal_alternative[goal_alternative_matches[i]]
                != NO_REGS))
          operand_reloadnum[i] = operand_reloadnum[goal_alternative_matches[i]]
-           = push_reload (recog_operand[goal_alternative_matches[i]],
-                          recog_operand[i],
-                          recog_operand_loc[goal_alternative_matches[i]],
-                          recog_operand_loc[i],
+           = push_reload (recog_data.operand[goal_alternative_matches[i]],
+                          recog_data.operand[i],
+                          recog_data.operand_loc[goal_alternative_matches[i]],
+                          recog_data.operand_loc[i],
                           (enum reg_class) goal_alternative[goal_alternative_matches[i]],
                           operand_mode[goal_alternative_matches[i]],
                           operand_mode[i],
                           0, 1, goal_alternative_matches[i], RELOAD_OTHER);
       }
-  
+
   /* Perform whatever substitutions on the operands we are supposed
      to make due to commutativity or replacement of registers
      with equivalent constants or memory slots.  */
@@ -3818,14 +3808,28 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
   for (i = 0; i < noperands; i++)
     {
       /* We only do this on the last pass through reload, because it is
-       possible for some data (like reg_equiv_address) to be changed during
-       later passes.  Moreover, we loose the opportunity to get a useful
-       reload_{in,out}_reg when we do these replacements.  */
+        possible for some data (like reg_equiv_address) to be changed during
+        later passes.  Moreover, we loose the opportunity to get a useful
+        reload_{in,out}_reg when we do these replacements.  */
 
       if (replace)
-       *recog_operand_loc[i] = substed_operand[i];
+       {
+         rtx substitution = substed_operand[i];
+
+         *recog_data.operand_loc[i] = substitution;
+
+         /* If we're replacing an operand with a LABEL_REF, we need
+            to make sure that there's a REG_LABEL note attached to
+            this instruction.  */
+         if (GET_CODE (insn) != JUMP_INSN
+             && GET_CODE (substitution) == LABEL_REF
+             && !find_reg_note (insn, REG_LABEL, XEXP (substitution, 0)))
+           REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_LABEL,
+                                                 XEXP (substitution, 0),
+                                                 REG_NOTES (insn));
+       }
       else
-       retval |= (substed_operand[i] != *recog_operand_loc[i]);
+       retval |= (substed_operand[i] != *recog_data.operand_loc[i]);
     }
 
   /* If this insn pattern contains any MATCH_DUP's, make sure that
@@ -3837,13 +3841,13 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
      it doesn't expect.  */
 
   if (insn_code_number >= 0 && replace)
-    for (i = insn_n_dups[insn_code_number] - 1; i >= 0; i--)
+    for (i = insn_data[insn_code_number].n_dups - 1; i >= 0; i--)
       {
-       int opno = recog_dup_num[i];
-       *recog_dup_loc[i] = *recog_operand_loc[opno];
+       int opno = recog_data.dup_num[i];
+       *recog_data.dup_loc[i] = *recog_data.operand_loc[opno];
        if (operand_reloadnum[opno] >= 0)
-         push_replacement (recog_dup_loc[i], operand_reloadnum[opno],
-                           insn_operand_mode[insn_code_number][opno]);
+         push_replacement (recog_data.dup_loc[i], operand_reloadnum[opno],
+                           insn_data[insn_code_number].operand[opno].mode);
       }
 
 #if 0
@@ -3857,18 +3861,18 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
      search for an existing equivalent reg (same value now) in the right class.
      We can use it as long as we don't need to change its contents.  */
   for (i = 0; i < n_reloads; i++)
-    if (reload_reg_rtx[i] == 0
-       && reload_in[i] != 0
-       && GET_CODE (reload_in[i]) == REG
-       && reload_out[i] == 0)
+    if (rld[i].reg_rtx == 0
+       && rld[i].in != 0
+       && GET_CODE (rld[i].in) == REG
+       && rld[i].out == 0)
       {
-       reload_reg_rtx[i]
-         = find_equiv_reg (reload_in[i], insn, reload_reg_class[i], -1,
-                           static_reload_reg_p, 0, reload_inmode[i]);
+       rld[i].reg_rtx
+         = find_equiv_reg (rld[i].in, insn, rld[i].class, -1,
+                           static_reload_reg_p, 0, rld[i].inmode);
        /* Prevent generation of insn to load the value
           because the one we found already has the value.  */
-       if (reload_reg_rtx[i])
-         reload_in[i] = reload_reg_rtx[i];
+       if (rld[i].reg_rtx)
+         rld[i].in = rld[i].reg_rtx;
       }
 #endif
 
@@ -3887,37 +3891,37 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       int k;
 
       for (j = i + 1; j < n_reloads; j++)
-       if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
-            || reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS
-            || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS
-            || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS)
-           && (reload_when_needed[j] == RELOAD_FOR_INPUT_ADDRESS
-               || reload_when_needed[j] == RELOAD_FOR_OUTPUT_ADDRESS
-               || reload_when_needed[j] == RELOAD_FOR_INPADDR_ADDRESS
-               || reload_when_needed[j] == RELOAD_FOR_OUTADDR_ADDRESS)
-           && rtx_equal_p (reload_in[i], reload_in[j])
-           && (operand_reloadnum[reload_opnum[i]] < 0
-               || reload_optional[operand_reloadnum[reload_opnum[i]]])
-           && (operand_reloadnum[reload_opnum[j]] < 0
-               || reload_optional[operand_reloadnum[reload_opnum[j]]])
-           && (goal_alternative_matches[reload_opnum[i]] == reload_opnum[j]
-               || (goal_alternative_matches[reload_opnum[j]]
-                   == reload_opnum[i])))
+       if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
+            || rld[i].when_needed == RELOAD_FOR_OUTPUT_ADDRESS
+            || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+            || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+           && (rld[j].when_needed == RELOAD_FOR_INPUT_ADDRESS
+               || rld[j].when_needed == RELOAD_FOR_OUTPUT_ADDRESS
+               || rld[j].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+               || rld[j].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+           && rtx_equal_p (rld[i].in, rld[j].in)
+           && (operand_reloadnum[rld[i].opnum] < 0
+               || rld[operand_reloadnum[rld[i].opnum]].optional)
+           && (operand_reloadnum[rld[j].opnum] < 0
+               || rld[operand_reloadnum[rld[j].opnum]].optional)
+           && (goal_alternative_matches[rld[i].opnum] == rld[j].opnum
+               || (goal_alternative_matches[rld[j].opnum]
+                   == rld[i].opnum)))
          {
            for (k = 0; k < n_replacements; k++)
              if (replacements[k].what == j)
                replacements[k].what = i;
 
-           if (reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS
-               || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS)
-             reload_when_needed[i] = RELOAD_FOR_OPADDR_ADDR;
+           if (rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+               || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+             rld[i].when_needed = RELOAD_FOR_OPADDR_ADDR;
            else
-             reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS;
-           reload_in[j] = 0;
+             rld[i].when_needed = RELOAD_FOR_OPERAND_ADDRESS;
+           rld[j].in = 0;
          }
     }
 
-  /* Scan all the reloads and update their type. 
+  /* Scan all the reloads and update their type.
      If a reload is for the address of an operand and we didn't reload
      that operand, change the type.  Similarly, change the operand number
      of a reload when two operands match.  If a reload is optional, treat it
@@ -3936,68 +3940,66 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
   for (i = 0; i < n_reloads; i++)
     {
-      if (reload_secondary_p[i]
-         && reload_when_needed[i] == operand_type[reload_opnum[i]])
-       reload_when_needed[i] = address_type[reload_opnum[i]];
-
-      if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
-          || reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS
-          || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS
-          || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS)
-         && (operand_reloadnum[reload_opnum[i]] < 0
-             || reload_optional[operand_reloadnum[reload_opnum[i]]]))
+      if (rld[i].secondary_p
+         && rld[i].when_needed == operand_type[rld[i].opnum])
+       rld[i].when_needed = address_type[rld[i].opnum];
+
+      if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
+          || rld[i].when_needed == RELOAD_FOR_OUTPUT_ADDRESS
+          || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+          || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+         && (operand_reloadnum[rld[i].opnum] < 0
+             || rld[operand_reloadnum[rld[i].opnum]].optional))
        {
          /* If we have a secondary reload to go along with this reload,
             change its type to RELOAD_FOR_OPADDR_ADDR.  */
 
-         if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
-              || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS)
-             && reload_secondary_in_reload[i] != -1)
+         if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
+              || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS)
+             && rld[i].secondary_in_reload != -1)
            {
-             int secondary_in_reload = reload_secondary_in_reload[i];
+             int secondary_in_reload = rld[i].secondary_in_reload;
 
-             reload_when_needed[secondary_in_reload]
-               = RELOAD_FOR_OPADDR_ADDR;
+             rld[secondary_in_reload].when_needed = RELOAD_FOR_OPADDR_ADDR;
 
              /* If there's a tertiary reload we have to change it also.  */
              if (secondary_in_reload > 0
-                 && reload_secondary_in_reload[secondary_in_reload] != -1)
-               reload_when_needed[reload_secondary_in_reload[secondary_in_reload]] 
+                 && rld[secondary_in_reload].secondary_in_reload != -1)
+               rld[rld[secondary_in_reload].secondary_in_reload].when_needed
                  = RELOAD_FOR_OPADDR_ADDR;
            }
 
-         if ((reload_when_needed[i] == RELOAD_FOR_OUTPUT_ADDRESS
-              || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS)
-             && reload_secondary_out_reload[i] != -1)
+         if ((rld[i].when_needed == RELOAD_FOR_OUTPUT_ADDRESS
+              || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+             && rld[i].secondary_out_reload != -1)
            {
-             int secondary_out_reload = reload_secondary_out_reload[i];
+             int secondary_out_reload = rld[i].secondary_out_reload;
 
-             reload_when_needed[secondary_out_reload]
-               = RELOAD_FOR_OPADDR_ADDR;
+             rld[secondary_out_reload].when_needed = RELOAD_FOR_OPADDR_ADDR;
 
              /* If there's a tertiary reload we have to change it also.  */
              if (secondary_out_reload
-                 && reload_secondary_out_reload[secondary_out_reload] != -1)
-               reload_when_needed[reload_secondary_out_reload[secondary_out_reload]] 
+                 && rld[secondary_out_reload].secondary_out_reload != -1)
+               rld[rld[secondary_out_reload].secondary_out_reload].when_needed
                  = RELOAD_FOR_OPADDR_ADDR;
            }
 
-         if (reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS
-             || reload_when_needed[i] == RELOAD_FOR_OUTADDR_ADDRESS)
-           reload_when_needed[i] = RELOAD_FOR_OPADDR_ADDR;
+         if (rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+             || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+           rld[i].when_needed = RELOAD_FOR_OPADDR_ADDR;
          else
-           reload_when_needed[i] = RELOAD_FOR_OPERAND_ADDRESS;
+           rld[i].when_needed = RELOAD_FOR_OPERAND_ADDRESS;
        }
 
-      if ((reload_when_needed[i] == RELOAD_FOR_INPUT_ADDRESS
-          || reload_when_needed[i] == RELOAD_FOR_INPADDR_ADDRESS)
-         && operand_reloadnum[reload_opnum[i]] >= 0
-         && (reload_when_needed[operand_reloadnum[reload_opnum[i]]] 
+      if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
+          || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS)
+         && operand_reloadnum[rld[i].opnum] >= 0
+         && (rld[operand_reloadnum[rld[i].opnum]].when_needed
              == RELOAD_OTHER))
-       reload_when_needed[i] = RELOAD_FOR_OTHER_ADDRESS;
+       rld[i].when_needed = RELOAD_FOR_OTHER_ADDRESS;
 
-      if (goal_alternative_matches[reload_opnum[i]] >= 0)
-       reload_opnum[i] = goal_alternative_matches[reload_opnum[i]];
+      if (goal_alternative_matches[rld[i].opnum] >= 0)
+       rld[i].opnum = goal_alternative_matches[rld[i].opnum];
     }
 
   /* Scan all the reloads, and check for RELOAD_FOR_OPERAND_ADDRESS reloads.
@@ -4027,7 +4029,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
     int first_op_addr_num = -2;
     int first_inpaddr_num[MAX_RECOG_OPERANDS];
     int first_outpaddr_num[MAX_RECOG_OPERANDS];
-    int need_change= 0;
+    int need_change = 0;
     /* We use last_op_addr_reload and the contents of the above arrays
        first as flags - -2 means no instance encountered, -1 means exactly
        one instance encountered.
@@ -4038,7 +4040,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       first_inpaddr_num[i] = first_outpaddr_num[i] = -2;
     for (i = n_reloads - 1; i >= 0; i--)
       {
-       switch (reload_when_needed[i])
+       switch (rld[i].when_needed)
          {
          case RELOAD_FOR_OPERAND_ADDRESS:
            if (++first_op_addr_num >= 0)
@@ -4048,16 +4050,16 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
              }
            break;
          case RELOAD_FOR_INPUT_ADDRESS:
-           if (++first_inpaddr_num[reload_opnum[i]] >= 0)
+           if (++first_inpaddr_num[rld[i].opnum] >= 0)
              {
-               first_inpaddr_num[reload_opnum[i]] = i;
+               first_inpaddr_num[rld[i].opnum] = i;
                need_change = 1;
              }
            break;
          case RELOAD_FOR_OUTPUT_ADDRESS:
-           if (++first_outpaddr_num[reload_opnum[i]] >= 0)
+           if (++first_outpaddr_num[rld[i].opnum] >= 0)
              {
-               first_outpaddr_num[reload_opnum[i]] = i;
+               first_outpaddr_num[rld[i].opnum] = i;
                need_change = 1;
              }
            break;
@@ -4070,20 +4072,21 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
       {
        for (i = 0; i < n_reloads; i++)
          {
-           int first_num, type;
+           int first_num;
+           enum reload_type type;
 
-           switch (reload_when_needed[i])
+           switch (rld[i].when_needed)
              {
              case RELOAD_FOR_OPADDR_ADDR:
                first_num = first_op_addr_num;
                type = RELOAD_FOR_OPERAND_ADDRESS;
                break;
              case RELOAD_FOR_INPADDR_ADDRESS:
-               first_num = first_inpaddr_num[reload_opnum[i]];
+               first_num = first_inpaddr_num[rld[i].opnum];
                type = RELOAD_FOR_INPUT_ADDRESS;
                break;
              case RELOAD_FOR_OUTADDR_ADDRESS:
-               first_num = first_outpaddr_num[reload_opnum[i]];
+               first_num = first_outpaddr_num[rld[i].opnum];
                type = RELOAD_FOR_OUTPUT_ADDRESS;
                break;
              default:
@@ -4092,19 +4095,19 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
            if (first_num < 0)
              continue;
            else if (i > first_num)
-             reload_when_needed[i] = type;
+             rld[i].when_needed = type;
            else
              {
                /* Check if the only TYPE reload that uses reload I is
                   reload FIRST_NUM.  */
                for (j = n_reloads - 1; j > first_num; j--)
                  {
-                   if (reload_when_needed[j] == type
-                       && (reload_secondary_p[i]
-                           ? reload_secondary_in_reload[j] == i
-                           : reg_mentioned_p (reload_in[i], reload_in[j])))
+                   if (rld[j].when_needed == type
+                       && (rld[i].secondary_p
+                           ? rld[j].secondary_in_reload == i
+                           : reg_mentioned_p (rld[i].in, rld[j].in)))
                      {
-                       reload_when_needed[i] = type;
+                       rld[i].when_needed = type;
                        break;
                      }
                  }
@@ -4119,151 +4122,47 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
      check for the most common cases.  */
 
   for (i = 0; i < n_reloads; i++)
-    if (reload_in[i] != 0 && reload_out[i] == 0
-       && (reload_when_needed[i] == RELOAD_FOR_OPERAND_ADDRESS
-           || reload_when_needed[i] == RELOAD_FOR_OPADDR_ADDR
-           || reload_when_needed[i] == RELOAD_FOR_OTHER_ADDRESS))
+    if (rld[i].in != 0 && rld[i].out == 0
+       && (rld[i].when_needed == RELOAD_FOR_OPERAND_ADDRESS
+           || rld[i].when_needed == RELOAD_FOR_OPADDR_ADDR
+           || rld[i].when_needed == RELOAD_FOR_OTHER_ADDRESS))
       for (j = 0; j < n_reloads; j++)
-       if (i != j && reload_in[j] != 0 && reload_out[j] == 0
-           && reload_when_needed[j] == reload_when_needed[i]
-           && MATCHES (reload_in[i], reload_in[j])
-           && reload_reg_class[i] == reload_reg_class[j]
-           && !reload_nocombine[i] && !reload_nocombine[j]
-           && reload_reg_rtx[i] == reload_reg_rtx[j])
+       if (i != j && rld[j].in != 0 && rld[j].out == 0
+           && rld[j].when_needed == rld[i].when_needed
+           && MATCHES (rld[i].in, rld[j].in)
+           && rld[i].class == rld[j].class
+           && !rld[i].nocombine && !rld[j].nocombine
+           && rld[i].reg_rtx == rld[j].reg_rtx)
          {
-           reload_opnum[i] = MIN (reload_opnum[i], reload_opnum[j]);
+           rld[i].opnum = MIN (rld[i].opnum, rld[j].opnum);
            transfer_replacements (i, j);
-           reload_in[j] = 0;
+           rld[j].in = 0;
          }
 
-  /* Set which reloads must use registers not used in any group.  Start
-     with those that conflict with a group and then include ones that
-     conflict with ones that are already known to conflict with a group.  */
+#ifdef HAVE_cc0
+  /* If we made any reloads for addresses, see if they violate a
+     "no input reloads" requirement for this insn.  But loads that we
+     do after the insn (such as for output addresses) are fine.  */
+  if (no_input_reloads)
+    for (i = 0; i < n_reloads; i++)
+      if (rld[i].in != 0
+         && rld[i].when_needed != RELOAD_FOR_OUTADDR_ADDRESS
+         && rld[i].when_needed != RELOAD_FOR_OUTPUT_ADDRESS)
+       abort ();
+#endif
 
-  changed = 0;
+  /* Compute reload_mode and reload_nregs.  */
   for (i = 0; i < n_reloads; i++)
     {
-      enum machine_mode mode = reload_inmode[i];
-      enum reg_class class = reload_reg_class[i];
-      int size;
-
-      if (GET_MODE_SIZE (reload_outmode[i]) > GET_MODE_SIZE (mode))
-       mode = reload_outmode[i];
-      size = CLASS_MAX_NREGS (class, mode);
-
-      if (size == 1)
-       for (j = 0; j < n_reloads; j++)
-         if ((CLASS_MAX_NREGS (reload_reg_class[j],
-                               (GET_MODE_SIZE (reload_outmode[j])
-                                > GET_MODE_SIZE (reload_inmode[j]))
-                               ? reload_outmode[j] : reload_inmode[j])
-              > 1)
-             && !reload_optional[j]
-             && (reload_in[j] != 0 || reload_out[j] != 0
-                 || reload_secondary_p[j])
-             && reloads_conflict (i, j)
-             && reg_classes_intersect_p (class, reload_reg_class[j]))
-           {
-             reload_nongroup[i] = 1;
-             changed = 1;
-             break;
-           }
-    }
-
-  while (changed)
-    {
-      changed = 0;
+      rld[i].mode
+       = (rld[i].inmode == VOIDmode
+          || (GET_MODE_SIZE (rld[i].outmode)
+              > GET_MODE_SIZE (rld[i].inmode)))
+         ? rld[i].outmode : rld[i].inmode;
 
-      for (i = 0; i < n_reloads; i++)
-       {
-         enum machine_mode mode = reload_inmode[i];
-         enum reg_class class = reload_reg_class[i];
-         int size;
-
-         if (GET_MODE_SIZE (reload_outmode[i]) > GET_MODE_SIZE (mode))
-           mode = reload_outmode[i];
-         size = CLASS_MAX_NREGS (class, mode);
-
-         if (! reload_nongroup[i] && size == 1)
-           for (j = 0; j < n_reloads; j++)
-             if (reload_nongroup[j]
-                 && reloads_conflict (i, j)
-                 && reg_classes_intersect_p (class, reload_reg_class[j]))
-               {
-                 reload_nongroup[i] = 1;
-                 changed = 1;
-                 break;
-               }
-       }
+      rld[i].nregs = CLASS_MAX_NREGS (rld[i].class, rld[i].mode);
     }
 
-#else /* no REGISTER_CONSTRAINTS */
-  int noperands;
-  int insn_code_number;
-  int goal_earlyclobber = 0; /* Always 0, to make combine_reloads happen.  */
-  register int i;
-  rtx body = PATTERN (insn);
-  int retval = 0;
-
-  n_reloads = 0;
-  n_replacements = 0;
-  n_earlyclobbers = 0;
-  replace_reloads = replace;
-  this_insn = insn;
-
-  extract_insn (insn);
-
-  noperands = reload_n_operands = recog_n_operands;
-
-  /* Return if the insn needs no reload processing.  */
-  if (noperands == 0)
-    return;
-
-  for (i = 0; i < noperands; i++)
-    {
-      register RTX_CODE code = GET_CODE (recog_operand[i]);
-      int is_set_dest = GET_CODE (body) == SET && (i == 0);
-
-      if (insn_code_number >= 0)
-       if (insn_operand_address_p[insn_code_number][i])
-         find_reloads_address (VOIDmode, NULL_PTR,
-                               recog_operand[i], recog_operand_loc[i],
-                               i, RELOAD_FOR_INPUT, ind_levels, insn);
-
-      /* In these cases, we can't tell if the operand is an input
-        or an output, so be conservative.  In practice it won't be
-        problem.  */
-
-      if (code == MEM)
-       find_reloads_address (GET_MODE (recog_operand[i]),
-                             recog_operand_loc[i],
-                             XEXP (recog_operand[i], 0),
-                             &XEXP (recog_operand[i], 0),
-                             i, RELOAD_OTHER, ind_levels, insn);
-      if (code == SUBREG)
-       recog_operand[i] = *recog_operand_loc[i]
-         = find_reloads_toplev (recog_operand[i], i, RELOAD_OTHER,
-                                ind_levels, is_set_dest);
-      if (code == REG)
-       {
-         register int regno = REGNO (recog_operand[i]);
-         if (reg_equiv_constant[regno] != 0 && !is_set_dest)
-           recog_operand[i] = *recog_operand_loc[i]
-             = reg_equiv_constant[regno];
-#if 0 /* This might screw code in reload1.c to delete prior output-reload
-        that feeds this insn.  */
-         if (reg_equiv_mem[regno] != 0)
-           recog_operand[i] = *recog_operand_loc[i]
-             = reg_equiv_mem[regno];
-#endif
-       }
-    }
-
-  /* Perhaps an output reload can be combined with another
-     to reduce needs by one.  */
-  if (!goal_earlyclobber)
-    combine_reloads ();
-#endif /* no REGISTER_CONSTRAINTS */
   return retval;
 }
 
@@ -4272,7 +4171,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
 
 static int
 alternative_allows_memconst (constraint, altnum)
-     char *constraint;
+     const char *constraint;
      int altnum;
 {
   register int c;
@@ -4307,21 +4206,27 @@ alternative_allows_memconst (constraint, altnum)
 
    INSN, if nonzero, is the insn in which we do the reload.  It is used
    to determine if we may generate output reloads, and where to put USEs
-   for pseudos that we have to replace with stack slots.  */
+   for pseudos that we have to replace with stack slots.
+
+   ADDRESS_RELOADED.  If nonzero, is a pointer to where we put the
+   result of find_reloads_address.  */
 
 static rtx
-find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
+find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn,
+                    address_reloaded)
      rtx x;
      int opnum;
      enum reload_type type;
      int ind_levels;
      int is_set_dest;
      rtx insn;
+     int *address_reloaded;
 {
   register RTX_CODE code = GET_CODE (x);
 
-  register char *fmt = GET_RTX_FORMAT (code);
+  register const char *fmt = GET_RTX_FORMAT (code);
   register int i;
+  int copied;
 
   if (code == REG)
     {
@@ -4330,8 +4235,8 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
       if (reg_equiv_constant[regno] != 0 && !is_set_dest)
        x = reg_equiv_constant[regno];
 #if 0
-/*  This creates (subreg (mem...)) which would cause an unnecessary
-    reload of the mem.  */
+      /*  This creates (subreg (mem...)) which would cause an unnecessary
+         reload of the mem.  */
       else if (reg_equiv_mem[regno] != 0)
        x = reg_equiv_mem[regno];
 #endif
@@ -4345,11 +4250,13 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
              /* If this is not a toplevel operand, find_reloads doesn't see
                 this substitution.  We have to emit a USE of the pseudo so
                 that delete_output_reload can see it.  */
-             if (replace_reloads && recog_operand[opnum] != x)
+             if (replace_reloads && recog_data.operand[opnum] != x)
                emit_insn_before (gen_rtx_USE (VOIDmode, x), insn);
              x = mem;
-             find_reloads_address (GET_MODE (x), &x, XEXP (x, 0), &XEXP (x, 0),
-                                   opnum, type, ind_levels, insn);
+             i = find_reloads_address (GET_MODE (x), &x, XEXP (x, 0), &XEXP (x, 0),
+                                       opnum, type, ind_levels, insn);
+             if (address_reloaded)
+               *address_reloaded = i;
            }
        }
       return x;
@@ -4357,14 +4264,18 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
   if (code == MEM)
     {
       rtx tem = x;
-      find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0),
-                           opnum, type, ind_levels, insn);
+
+      i = find_reloads_address (GET_MODE (x), &tem, XEXP (x, 0), &XEXP (x, 0),
+                               opnum, type, ind_levels, insn);
+      if (address_reloaded)
+       *address_reloaded = i;
+
       return tem;
     }
 
   if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG)
     {
-      /* Check for SUBREG containing a REG that's equivalent to a constant. 
+      /* Check for SUBREG containing a REG that's equivalent to a constant.
         If the constant has a known value, truncate it right now.
         Similarly if we are extracting a single-word of a multi-word
         constant.  If the constant is symbolic, allow it to be substituted
@@ -4412,18 +4323,18 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
          && GET_CODE (reg_equiv_constant[regno]) == CONST_INT
          && (GET_MODE_SIZE (GET_MODE (x))
              < GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))))
-         {
-           int shift = SUBREG_WORD (x) * BITS_PER_WORD;
-           if (WORDS_BIG_ENDIAN)
-             shift = (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))
-                      - GET_MODE_BITSIZE (GET_MODE (x))
-                      - shift);
-           /* Here we use the knowledge that CONST_INTs have a
-              HOST_WIDE_INT field.  */
-           if (shift >= HOST_BITS_PER_WIDE_INT)
-             shift = HOST_BITS_PER_WIDE_INT - 1;
-           return GEN_INT (INTVAL (reg_equiv_constant[regno]) >> shift);
-         }
+       {
+         int shift = SUBREG_WORD (x) * BITS_PER_WORD;
+         if (WORDS_BIG_ENDIAN)
+           shift = (GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (x)))
+                    - GET_MODE_BITSIZE (GET_MODE (x))
+                    - shift);
+         /* Here we use the knowledge that CONST_INTs have a
+            HOST_WIDE_INT field.  */
+         if (shift >= HOST_BITS_PER_WIDE_INT)
+           shift = HOST_BITS_PER_WIDE_INT - 1;
+         return GEN_INT (INTVAL (reg_equiv_constant[regno]) >> shift);
+       }
 
       if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] < 0
          && reg_equiv_constant[regno] != 0
@@ -4450,45 +4361,52 @@ find_reloads_toplev (x, opnum, type, ind_levels, is_set_dest, insn)
 #endif
               && (reg_equiv_address[regno] != 0
                   || (reg_equiv_mem[regno] != 0
-                      && (! strict_memory_address_p (GET_MODE (x), 
+                      && (! strict_memory_address_p (GET_MODE (x),
                                                      XEXP (reg_equiv_mem[regno], 0))
                           || ! offsettable_memref_p (reg_equiv_mem[regno])
                           || num_not_at_initial_offset))))
-       {
-         int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
-         /* We must rerun eliminate_regs, in case the elimination
-            offsets have changed.  */
-         rtx addr = XEXP (eliminate_regs (reg_equiv_memory_loc[regno], 0,
-                                          NULL_RTX),
-                          0);
-         if (BYTES_BIG_ENDIAN)
-           {
-             int size;
-             size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
-             offset += MIN (size, UNITS_PER_WORD);
-             size = GET_MODE_SIZE (GET_MODE (x));
-             offset -= MIN (size, UNITS_PER_WORD);
-           }
-         addr = plus_constant (addr, offset);
-         x = gen_rtx_MEM (GET_MODE (x), addr);
-         RTX_UNCHANGING_P (x) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
-         find_reloads_address (GET_MODE (x), &x,
-                               XEXP (x, 0),
-                               &XEXP (x, 0), opnum, type, ind_levels, insn);
-         /* If this is not a toplevel operand, find_reloads doesn't see this
-            substitution.  We have to emit a USE of the pseudo so that
-            delete_output_reload can see it.  */
-         if (replace_reloads && recog_operand[opnum] != x)
-           emit_insn_before (gen_rtx_USE (VOIDmode, SUBREG_REG (x)), insn);
-       }
-
+       x = find_reloads_subreg_address (x, 1, opnum, type, ind_levels,
+                                        insn);
+    }
+  else if (code == SUBREG && GET_CODE (SUBREG_REG (x)) == MEM
+          && (GET_MODE_SIZE (GET_MODE (x))
+              > GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
+          && mode_dependent_address_p (XEXP (SUBREG_REG (x), 0)))
+    {
+      /* A paradoxical subreg will simply have the mode of the access
+        changed, so we need to reload such a memory operand to stabilize
+        the meaning of the memory access.  */
+      enum machine_mode subreg_mode = GET_MODE (SUBREG_REG (x));
+
+      if (is_set_dest)
+       push_reload (NULL_RTX, SUBREG_REG (x), NULL_PTR, &SUBREG_REG (x),
+                    find_valid_class (subreg_mode, SUBREG_WORD (x)),
+                    VOIDmode, subreg_mode, 0, 0, opnum, type);
+      else
+       push_reload (SUBREG_REG (x), NULL_RTX, &SUBREG_REG (x), NULL_PTR,
+                    find_valid_class (subreg_mode, SUBREG_WORD (x)),
+                    subreg_mode, VOIDmode, 0, 0, opnum, type);
     }
 
-  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+  for (copied = 0, i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
     {
       if (fmt[i] == 'e')
-       XEXP (x, i) = find_reloads_toplev (XEXP (x, i), opnum, type,
-                                          ind_levels, is_set_dest, insn);
+       {
+         rtx new_part = find_reloads_toplev (XEXP (x, i), opnum, type,
+                                             ind_levels, is_set_dest, insn,
+                                             address_reloaded);
+         /* If we have replaced a reg with it's equivalent memory loc -
+            that can still be handled here e.g. if it's in a paradoxical
+            subreg - we must make the change in a copy, rather than using
+            a destructive change.  This way, find_reloads can still elect
+            not to do the change.  */
+         if (new_part != XEXP (x, i) && ! CONSTANT_P (new_part) && ! copied)
+           {
+             x = shallow_copy_rtx (x);
+             copied = 1;
+           }
+         XEXP (x, i) = new_part;
+       }
     }
   return x;
 }
@@ -4512,7 +4430,7 @@ make_memloc (ad, regno)
     tem = copy_rtx (tem);
 
   tem = gen_rtx_MEM (GET_MODE (ad), tem);
-  RTX_UNCHANGING_P (tem) = RTX_UNCHANGING_P (regno_reg_rtx[regno]);
+  MEM_COPY_ATTRIBUTES (tem, reg_equiv_memory_loc[regno]);
   return tem;
 }
 
@@ -4552,6 +4470,7 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
      rtx insn;
 {
   register int regno;
+  int removed_and = 0;
   rtx tem;
 
   /* If the address is a register, see if it is a legitimate address and
@@ -4566,7 +4485,7 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
          && strict_memory_address_p (mode, reg_equiv_constant[regno]))
        {
          *loc = ad = reg_equiv_constant[regno];
-         return 1;
+         return 0;
        }
 
       tem = reg_equiv_memory_loc[regno];
@@ -4617,7 +4536,7 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
 
       else if (regno < FIRST_PSEUDO_REGISTER
               && REGNO_MODE_OK_FOR_BASE_P (regno, mode)
-              && ! regno_clobbered_p (regno, this_insn))
+              && ! regno_clobbered_p (regno, this_insn, mode, 0))
        return 0;
 
       /* If we do not have one of the cases above, we must do the reload.  */
@@ -4671,12 +4590,22 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
   while (0);
 #endif
 
-  /* The address is not valid.  We have to figure out why.  One possibility
-     is that it is itself a MEM.  This can happen when the frame pointer is
-     being eliminated, a pseudo is not allocated to a hard register, and the
-     offset between the frame and stack pointers is not its initial value.
-     In that case the pseudo will have been replaced by a MEM referring to
-     the stack pointer.  */
+  /* The address is not valid.  We have to figure out why.  First see if
+     we have an outer AND and remove it if so.  Then analyze what's inside.  */
+
+  if (GET_CODE (ad) == AND)
+    {
+      removed_and = 1;
+      loc = &XEXP (ad, 0);
+      ad = *loc;
+    }
+
+  /* One possibility for why the address is invalid is that it is itself
+     a MEM.  This can happen when the frame pointer is being eliminated, a
+     pseudo is not allocated to a hard register, and the offset between the
+     frame and stack pointers is not its initial value.  In that case the
+     pseudo will have been replaced by a MEM referring to the
+     stack pointer.  */
   if (GET_CODE (ad) == MEM)
     {
       /* First ensure that the address in this MEM is valid.  Then, unless
@@ -4693,6 +4622,8 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
          *memrefloc = copy_rtx (*memrefloc);
          copy_replacements (tem, XEXP (*memrefloc, 0));
          loc = &XEXP (*memrefloc, 0);
+         if (removed_and)
+           loc = &XEXP (*loc, 0);
        }
 
       /* Check similar cases as for indirect addresses as above except
@@ -4713,7 +4644,7 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
                       BASE_REG_CLASS, GET_MODE (tem),
                       VOIDmode, 0,
                       0, opnum, type);
-         return 1;
+         return ! removed_and;
        }
       else
        return 0;
@@ -4735,16 +4666,21 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
        {
          *memrefloc = copy_rtx (*memrefloc);
          loc = &XEXP (*memrefloc, 0);
+         if (removed_and)
+           loc = &XEXP (*loc, 0);
        }
+
       if (double_reg_address_ok)
        {
          /* Unshare the sum as well.  */
          *loc = ad = copy_rtx (ad);
+
          /* Reload the displacement into an index reg.
             We assume the frame pointer or arg pointer is a base reg.  */
          find_reloads_address_part (XEXP (ad, 1), &XEXP (ad, 1),
                                     INDEX_REG_CLASS, GET_MODE (ad), opnum,
                                     type, ind_levels);
+         return 0;
        }
       else
        {
@@ -4754,13 +4690,13 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
          find_reloads_address_part (ad, loc, BASE_REG_CLASS,
                                     Pmode, opnum, type, ind_levels);
        }
-      return 1;
+      return ! removed_and;
     }
 
   /* If we have an indexed stack slot, there are three possible reasons why
      it might be invalid: The index might need to be reloaded, the address
      might have been made by frame pointer elimination and hence have a
-     constant out of range, or both reasons might apply.  
+     constant out of range, or both reasons might apply.
 
      We can easily check for an index needing reload, but even if that is the
      case, we might also have an invalid constant.  To avoid making the
@@ -4769,14 +4705,6 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
      that the index needs a reload and find_reloads_address_1 will take care
      of it.
 
-     There is still a case when we might generate an extra reload,
-     however.  In certain cases eliminate_regs will return a MEM for a REG
-     (see the code there for details).  In those cases, memory_address_p
-     applied to our address will return 0 so we will think that our offset
-     must be too large.  But it might indeed be valid and the only problem
-     is that a MEM is present where a REG should be.  This case should be
-     very rare and there doesn't seem to be any way to avoid it.
-
      If we decide to do something here, it must be that
      `double_reg_address_ok' is true and that this address rtl was made by
      eliminate_regs.  We generate a reload of the fp/sp/ap + constant and
@@ -4801,15 +4729,15 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
       *loc = ad = gen_rtx_PLUS (GET_MODE (ad),
                                plus_constant (XEXP (XEXP (ad, 0), 0),
                                               INTVAL (XEXP (ad, 1))),
-                          XEXP (XEXP (ad, 0), 1));
+                               XEXP (XEXP (ad, 0), 1));
       find_reloads_address_part (XEXP (ad, 0), &XEXP (ad, 0), BASE_REG_CLASS,
                                 GET_MODE (ad), opnum, type, ind_levels);
       find_reloads_address_1 (mode, XEXP (ad, 1), 1, &XEXP (ad, 1), opnum,
                              type, 0, insn);
 
-      return 1;
+      return 0;
     }
-                          
+
   else if (GET_CODE (ad) == PLUS && GET_CODE (XEXP (ad, 1)) == CONST_INT
           && GET_CODE (XEXP (ad, 0)) == PLUS
           && (XEXP (XEXP (ad, 0), 1) == frame_pointer_rtx
@@ -4831,9 +4759,9 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
       find_reloads_address_1 (mode, XEXP (ad, 0), 1, &XEXP (ad, 0), opnum,
                              type, 0, insn);
 
-      return 1;
+      return 0;
     }
-                          
+
   /* See if address becomes valid when an eliminable register
      in a sum is replaced.  */
 
@@ -4868,11 +4796,13 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
        {
          *memrefloc = copy_rtx (*memrefloc);
          loc = &XEXP (*memrefloc, 0);
+         if (removed_and)
+           loc = &XEXP (*loc, 0);
        }
 
       find_reloads_address_part (ad, loc, BASE_REG_CLASS, Pmode, opnum, type,
                                 ind_levels);
-      return 1;
+      return ! removed_and;
     }
 
   return find_reloads_address_1 (mode, ad, 0, loc, opnum, type, ind_levels,
@@ -4892,7 +4822,7 @@ subst_reg_equivs (ad, insn)
 {
   register RTX_CODE code = GET_CODE (ad);
   register int i;
-  register char *fmt;
+  register const char *fmt;
 
   switch (code)
     {
@@ -4934,7 +4864,7 @@ subst_reg_equivs (ad, insn)
          && GET_CODE (XEXP (ad, 1)) == CONST_INT)
        return ad;
       break;
-      
+
     default:
       break;
     }
@@ -5026,9 +4956,9 @@ subst_indexed_address (addr)
          && reg_equiv_constant[regno] != 0)
        op0 = reg_equiv_constant[regno];
       else if (GET_CODE (op1) == REG
-         && (regno = REGNO (op1)) >= FIRST_PSEUDO_REGISTER
-         && reg_renumber[regno] < 0
-         && reg_equiv_constant[regno] != 0)
+              && (regno = REGNO (op1)) >= FIRST_PSEUDO_REGISTER
+              && reg_renumber[regno] < 0
+              && reg_equiv_constant[regno] != 0)
        op1 = reg_equiv_constant[regno];
       else if (GET_CODE (op0) == PLUS
               && (tem = subst_indexed_address (op0)) != op0)
@@ -5122,7 +5052,7 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
                                 REGNO (op1) + SUBREG_WORD (orig_op1));
          }
 
-       if (code0 == MULT || code0 == SIGN_EXTEND || code0 == TRUNCATE 
+       if (code0 == MULT || code0 == SIGN_EXTEND || code0 == TRUNCATE
            || code0 == ZERO_EXTEND || code1 == MEM)
          {
            find_reloads_address_1 (mode, orig_op0, 1, &XEXP (x, 0), opnum,
@@ -5198,6 +5128,97 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
 
       return 0;
 
+    case POST_MODIFY:
+    case PRE_MODIFY:
+      {
+       rtx op0 = XEXP (x, 0);
+       rtx op1 = XEXP (x, 1);
+
+       if (GET_CODE (op1) != PLUS && GET_CODE (op1) != MINUS)
+         return 0;
+
+       /* Currently, we only support {PRE,POST}_MODIFY constructs
+          where a base register is {inc,dec}remented by the contents
+          of another register or by a constant value.  Thus, these
+          operands must match.  */
+       if (op0 != XEXP (op1, 0))
+         abort ();
+
+       /* Require index register (or constant).  Let's just handle the
+          register case in the meantime... If the target allows
+          auto-modify by a constant then we could try replacing a pseudo
+          register with its equivalent constant where applicable.  */
+       if (REG_P (XEXP (op1, 1)))
+         if (!REGNO_OK_FOR_INDEX_P (REGNO (XEXP (op1, 1))))
+           find_reloads_address_1 (mode, XEXP (op1, 1), 1, &XEXP (op1, 1),
+                                   opnum, type, ind_levels, insn);
+
+       if (REG_P (XEXP (op1, 0)))
+         {
+           rtx link;
+           int regno = REGNO (XEXP (op1, 0));
+           int reloadnum;
+
+           /* A register that is incremented cannot be constant!  */
+           if (regno >= FIRST_PSEUDO_REGISTER
+               && reg_equiv_constant[regno] != 0)
+             abort ();
+
+           /* Handle a register that is equivalent to a memory location
+              which cannot be addressed directly.  */
+           if (reg_equiv_memory_loc[regno] != 0
+               && (reg_equiv_address[regno] != 0
+                   || num_not_at_initial_offset))
+             {
+               rtx tem = make_memloc (XEXP (x, 0), regno);
+
+               if (reg_equiv_address[regno]
+                   || ! rtx_equal_p (tem, reg_equiv_mem[regno]))
+                 {
+                   /* First reload the memory location's address.
+                      We can't use ADDR_TYPE (type) here, because we need to
+                      write back the value after reading it, hence we actually
+                      need two registers.  */
+                   find_reloads_address (GET_MODE (tem), 0, XEXP (tem, 0),
+                                         &XEXP (tem, 0), opnum,
+                                         RELOAD_OTHER,
+                                         ind_levels, insn);
+
+                   /* Then reload the memory location into a base
+                      register.  */
+                   reloadnum = push_reload (tem, tem, &XEXP (x, 0),
+                                            &XEXP (op1, 0), BASE_REG_CLASS,
+                                            GET_MODE (x), GET_MODE (x), 0,
+                                            0, opnum, RELOAD_OTHER);
+                   goto reg_inc;
+                 }
+             }
+
+           if (reg_renumber[regno] >= 0)
+             regno = reg_renumber[regno];
+
+           /* We require a base register here...  */
+           if (!REGNO_MODE_OK_FOR_BASE_P (regno, GET_MODE (x)))
+             {
+               reloadnum = push_reload (XEXP (op1, 0), XEXP (x, 0),
+                                        &XEXP (op1, 0), &XEXP (x, 0),
+                                        BASE_REG_CLASS,
+                                        GET_MODE (x), GET_MODE (x), 0, 0,
+                                        opnum, RELOAD_OTHER);
+             }
+
+           /* Update the REG_INC notes.  */
+         reg_inc:
+           for (link = REG_NOTES (this_insn); link; link = XEXP (link, 1))
+             if (REG_NOTE_KIND (link) == REG_INC
+                 && REGNO (XEXP (link, 0)) == regno)
+               push_replacement (&XEXP (link, 0), reloadnum, VOIDmode);
+         }
+       else
+         abort ();
+      }
+      return 0;
+
     case POST_INC:
     case POST_DEC:
     case PRE_INC:
@@ -5275,16 +5296,23 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
                  && ! sets_cc0_p (PATTERN (insn))
 #endif
                  && ! (icode != CODE_FOR_nothing
-                       && (*insn_operand_predicate[icode][0]) (equiv, Pmode)
-                       && (*insn_operand_predicate[icode][1]) (equiv, Pmode)))
+                       && ((*insn_data[icode].operand[0].predicate)
+                           (equiv, Pmode))
+                       && ((*insn_data[icode].operand[1].predicate)
+                           (equiv, Pmode))))
                {
-                 loc = &XEXP (x, 0);
+                 /* We use the original pseudo for loc, so that
+                    emit_reload_insns() knows which pseudo this
+                    reload refers to and updates the pseudo rtx, not
+                    its equivalent memory location, as well as the
+                    corresponding entry in reg_last_reload_reg.  */
+                 loc = &XEXP (x_orig, 0);
                  x = XEXP (x, 0);
                  reloadnum
                    = push_reload (x, x, loc, loc,
                                   (context ? INDEX_REG_CLASS : BASE_REG_CLASS),
-                                   GET_MODE (x), GET_MODE (x), 0, 0,
-                                   opnum, RELOAD_OTHER);
+                                  GET_MODE (x), GET_MODE (x), 0, 0,
+                                  opnum, RELOAD_OTHER);
                }
              else
                {
@@ -5293,9 +5321,9 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
                                   (context ? INDEX_REG_CLASS : BASE_REG_CLASS),
                                   GET_MODE (x), GET_MODE (x), 0, 0,
                                   opnum, type);
-                 reload_inc[reloadnum]
+                 rld[reloadnum].inc
                    = find_inc_amount (PATTERN (this_insn), XEXP (x_orig, 0));
-    
+
                  value = 1;
                }
 
@@ -5318,7 +5346,8 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
             of an equivalent address for a pseudo that was not allocated to a
             hard register.  Verify that the specified address is valid and
             reload it into a register.  */
-         rtx tem = XEXP (x, 0);
+         /* Variable `tem' might or might not be used in FIND_REG_INC_NOTE.  */
+         rtx tem ATTRIBUTE_UNUSED = XEXP (x, 0);
          register rtx link;
          int reloadnum;
 
@@ -5338,7 +5367,7 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
          reloadnum = push_reload (x, NULL_RTX, loc, NULL_PTR,
                                   (context ? INDEX_REG_CLASS : BASE_REG_CLASS),
                                   GET_MODE (x), VOIDmode, 0, 0, opnum, type);
-         reload_inc[reloadnum]
+         rld[reloadnum].inc
            = find_inc_amount (PATTERN (this_insn), XEXP (x, 0));
 
          link = FIND_REG_INC_NOTE (this_insn, tem);
@@ -5423,7 +5452,7 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
           in this insn, reload it into some other register to be safe.
           The CLOBBER is supposed to make the register unavailable
           from before this insn to after it.  */
-       if (regno_clobbered_p (regno, this_insn))
+       if (regno_clobbered_p (regno, this_insn, GET_MODE (x), 0))
          {
            push_reload (x, NULL_RTX, loc, NULL_PTR,
                         (context ? INDEX_REG_CLASS : BASE_REG_CLASS),
@@ -5461,6 +5490,8 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
              if (CLASS_MAX_NREGS (class, GET_MODE (SUBREG_REG (x)))
                  > reg_class_size[class])
                {
+                 x = find_reloads_subreg_address (x, 0, opnum, type,
+                                                  ind_levels, insn);
                  push_reload (x, NULL_RTX, loc, NULL_PTR, class,
                               GET_MODE (x), VOIDmode, 0, 0, opnum, type);
                  return 1;
@@ -5468,13 +5499,13 @@ find_reloads_address_1 (mode, x, context, loc, opnum, type, ind_levels, insn)
            }
        }
       break;
-      
+
     default:
       break;
     }
 
   {
-    register char *fmt = GET_RTX_FORMAT (code);
+    register const char *fmt = GET_RTX_FORMAT (code);
     register int i;
 
     for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
@@ -5519,18 +5550,7 @@ find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels)
     {
       rtx tem;
 
-      /* If this is a CONST_INT, it could have been created by a
-        plus_constant call in eliminate_regs, which means it may be
-        on the reload_obstack.  reload_obstack will be freed later, so
-        we can't allow such RTL to be put in the constant pool.  There
-        is code in force_const_mem to check for this case, but it doesn't
-        work because we have already popped off the reload_obstack, so
-        rtl_obstack == saveable_obstack is true at this point.  */
-      if (GET_CODE (x) == CONST_INT)
-       tem = x = force_const_mem (mode, GEN_INT (INTVAL (x)));
-      else
-       tem = x = force_const_mem (mode, x);
-
+      tem = x = force_const_mem (mode, x);
       find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
                            opnum, type, ind_levels, 0);
     }
@@ -5542,12 +5562,7 @@ find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels)
     {
       rtx tem;
 
-      /* See comment above.  */
-      if (GET_CODE (XEXP (x, 1)) == CONST_INT)
-       tem = force_const_mem (GET_MODE (x), GEN_INT (INTVAL (XEXP (x, 1))));
-      else
-       tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
-
+      tem = force_const_mem (GET_MODE (x), XEXP (x, 1));
       x = gen_rtx_PLUS (GET_MODE (x), XEXP (x, 0), tem);
       find_reloads_address (mode, &tem, XEXP (tem, 0), &XEXP (tem, 0),
                            opnum, type, ind_levels, 0);
@@ -5557,9 +5572,89 @@ find_reloads_address_part (x, loc, class, mode, opnum, type, ind_levels)
               mode, VOIDmode, 0, 0, opnum, type);
 }
 \f
+/* X, a subreg of a pseudo, is a part of an address that needs to be
+   reloaded.
+
+   If the pseudo is equivalent to a memory location that cannot be directly
+   addressed, make the necessary address reloads.
+
+   If address reloads have been necessary, or if the address is changed
+   by register elimination, return the rtx of the memory location;
+   otherwise, return X.
+
+   If FORCE_REPLACE is nonzero, unconditionally replace the subreg with the
+   memory location.
+
+   OPNUM and TYPE identify the purpose of the reload.
+
+   IND_LEVELS says how many levels of indirect addressing are
+   supported at this point in the address.
+
+   INSN, if nonzero, is the insn in which we do the reload.  It is used
+   to determine where to put USEs for pseudos that we have to replace with
+   stack slots.  */
+
+static rtx
+find_reloads_subreg_address (x, force_replace, opnum, type,
+                            ind_levels, insn)
+     rtx x;
+     int force_replace;
+     int opnum;
+     enum reload_type type;
+     int ind_levels;
+     rtx insn;
+{
+  int regno = REGNO (SUBREG_REG (x));
+
+  if (reg_equiv_memory_loc[regno])
+    {
+      /* If the address is not directly addressable, or if the address is not
+        offsettable, then it must be replaced.  */
+      if (! force_replace
+         && (reg_equiv_address[regno]
+             || ! offsettable_memref_p (reg_equiv_mem[regno])))
+       force_replace = 1;
+
+      if (force_replace || num_not_at_initial_offset)
+       {
+         rtx tem = make_memloc (SUBREG_REG (x), regno);
+
+         /* If the address changes because of register elimination, then
+            it must be replaced.  */
+         if (force_replace
+             || ! rtx_equal_p (tem, reg_equiv_mem[regno]))
+           {
+             int offset = SUBREG_WORD (x) * UNITS_PER_WORD;
+
+             if (BYTES_BIG_ENDIAN)
+               {
+                 int size;
+
+                 size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)));
+                 offset += MIN (size, UNITS_PER_WORD);
+                 size = GET_MODE_SIZE (GET_MODE (x));
+                 offset -= MIN (size, UNITS_PER_WORD);
+               }
+             XEXP (tem, 0) = plus_constant (XEXP (tem, 0), offset);
+             PUT_MODE (tem, GET_MODE (x));
+             find_reloads_address (GET_MODE (tem), &tem, XEXP (tem, 0),
+                                   &XEXP (tem, 0), opnum, ADDR_TYPE (type),
+                                   ind_levels, insn);
+             /* If this is not a toplevel operand, find_reloads doesn't see
+                this substitution.  We have to emit a USE of the pseudo so
+                that delete_output_reload can see it.  */
+             if (replace_reloads && recog_data.operand[opnum] != x)
+               emit_insn_before (gen_rtx_USE (VOIDmode, SUBREG_REG (x)), insn);
+             x = tem;
+           }
+       }
+    }
+  return x;
+}
+\f
 /* Substitute into the current INSN the registers into which we have reloaded
    the things that need reloading.  The array `replacements'
-   says contains the locations of all pointers that must be changed
+   contains the locations of all pointers that must be changed
    and says what to replace them with.
 
    Return the rtx that X translates into; usually X, but modified.  */
@@ -5572,7 +5667,7 @@ subst_reloads ()
   for (i = 0; i < n_replacements; i++)
     {
       register struct replacement *r = &replacements[i];
-      register rtx reloadreg = reload_reg_rtx[r->what];
+      register rtx reloadreg = rld[r->what].reg_rtx;
       if (reloadreg)
        {
          /* Encapsulate RELOADREG so its machine mode matches what
@@ -5601,7 +5696,7 @@ subst_reloads ()
            *r->where = reloadreg;
        }
       /* If reload got no reg and isn't optional, something's wrong.  */
-      else if (! reload_optional[r->what])
+      else if (! rld[r->what].optional)
        abort ();
     }
 }
@@ -5617,7 +5712,7 @@ copy_replacements (x, y)
 {
   int i, j;
   enum rtx_code code = GET_CODE (x);
-  char *fmt = GET_RTX_FORMAT (code);
+  const char *fmt = GET_RTX_FORMAT (code);
   struct replacement *r;
 
   /* We can't support X being a SUBREG because we might then need to know its
@@ -5678,7 +5773,7 @@ find_replacement (loc)
 
   for (r = &replacements[0]; r < &replacements[n_replacements]; r++)
     {
-      rtx reloadreg = reload_reg_rtx[r->what];
+      rtx reloadreg = rld[r->what].reg_rtx;
 
       if (reloadreg && r->where == loc)
        {
@@ -5731,13 +5826,14 @@ find_replacement (loc)
 
 int
 refers_to_regno_for_reload_p (regno, endregno, x, loc)
-     int regno, endregno;
+     unsigned int regno, endregno;
      rtx x;
      rtx *loc;
 {
-  register int i;
-  register RTX_CODE code;
-  register char *fmt;
+  int i;
+  unsigned int r;
+  RTX_CODE code;
+  const char *fmt;
 
   if (x == 0)
     return 0;
@@ -5748,26 +5844,26 @@ refers_to_regno_for_reload_p (regno, endregno, x, loc)
   switch (code)
     {
     case REG:
-      i = REGNO (x);
+      r = REGNO (x);
 
       /* If this is a pseudo, a hard register must not have been allocated.
         X must therefore either be a constant or be in memory.  */
-      if (i >= FIRST_PSEUDO_REGISTER)
+      if (r >= FIRST_PSEUDO_REGISTER)
        {
-         if (reg_equiv_memory_loc[i])
+         if (reg_equiv_memory_loc[r])
            return refers_to_regno_for_reload_p (regno, endregno,
-                                                reg_equiv_memory_loc[i],
+                                                reg_equiv_memory_loc[r],
                                                 NULL_PTR);
 
-         if (reg_equiv_constant[i])
+         if (reg_equiv_constant[r])
            return 0;
 
          abort ();
        }
 
-      return (endregno > i
-             && regno < i + (i < FIRST_PSEUDO_REGISTER 
-                             ? HARD_REGNO_NREGS (i, GET_MODE (x))
+      return (endregno > r
+             && regno < r + (r < FIRST_PSEUDO_REGISTER
+                             ? HARD_REGNO_NREGS (r, GET_MODE (x))
                              : 1));
 
     case SUBREG:
@@ -5776,8 +5872,8 @@ refers_to_regno_for_reload_p (regno, endregno, x, loc)
       if (GET_CODE (SUBREG_REG (x)) == REG
          && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
        {
-         int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
-         int inner_endregno
+         unsigned int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
+         unsigned int inner_endregno
            = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
                             ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
 
@@ -5810,7 +5906,7 @@ refers_to_regno_for_reload_p (regno, endregno, x, loc)
        return 0;
       x = SET_SRC (x);
       goto repeat;
-      
+
     default:
       break;
     }
@@ -5835,7 +5931,7 @@ refers_to_regno_for_reload_p (regno, endregno, x, loc)
       else if (fmt[i] == 'E')
        {
          register int j;
-         for (j = XVECLEN (x, i) - 1; j >=0; j--)
+         for (j = XVECLEN (x, i) - 1; j >= 0; j--)
            if (loc != &XVECEXP (x, i, j)
                && refers_to_regno_for_reload_p (regno, endregno,
                                                 XVECEXP (x, i, j), loc))
@@ -5849,7 +5945,7 @@ refers_to_regno_for_reload_p (regno, endregno, x, loc)
    we check if any register number in X conflicts with the relevant register
    numbers.  If X is a constant, return 0.  If X is a MEM, return 1 iff IN
    contains a MEM (we don't bother checking for memory addresses that can't
-   conflict because we expect this to be a rare case. 
+   conflict because we expect this to be a rare case.
 
    This function is similar to reg_overlap_mention_p in rtlanal.c except
    that we look at equivalences for pseudos that didn't get hard registers.  */
@@ -5910,7 +6006,7 @@ int
 refers_to_mem_for_reload_p (x)
      rtx x;
 {
-  char *fmt;
+  const char *fmt;
   int i;
 
   if (GET_CODE (x) == MEM)
@@ -5919,14 +6015,14 @@ refers_to_mem_for_reload_p (x)
   if (GET_CODE (x) == REG)
     return (REGNO (x) >= FIRST_PSEUDO_REGISTER
            && reg_equiv_memory_loc[REGNO (x)]);
-                       
+
   fmt = GET_RTX_FORMAT (GET_CODE (x));
   for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
     if (fmt[i] == 'e'
        && (GET_CODE (XEXP (x, i)) == MEM
            || refers_to_mem_for_reload_p (XEXP (x, i))))
       return 1;
-  
+
   return 0;
 }
 \f
@@ -5997,6 +6093,8 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
        case PRE_INC:
        case POST_DEC:
        case PRE_DEC:
+       case POST_MODIFY:
+       case PRE_MODIFY:
          return 0;
        default:
          break;
@@ -6016,15 +6114,6 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
   else
     return 0;
 
-  /* On some machines, certain regs must always be rejected
-     because they don't behave the way ordinary registers do.  */
-  
-#ifdef OVERLAPPING_REGNO_P
-   if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
-       && OVERLAPPING_REGNO_P (regno))
-     return 0;
-#endif      
-
   /* Scan insns back from INSN, looking for one that copies
      a value into or out of GOAL.
      Stop and give up if we reach a label.  */
@@ -6034,21 +6123,24 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
       p = PREV_INSN (p);
       if (p == 0 || GET_CODE (p) == CODE_LABEL)
        return 0;
+
       if (GET_CODE (p) == INSN
          /* If we don't want spill regs ...  */
          && (! (reload_reg_p != 0
                 && reload_reg_p != (short *) (HOST_WIDE_INT) 1)
-         /* ... then ignore insns introduced by reload; they aren't useful
-            and can cause results in reload_as_needed to be different
-            from what they were when calculating the need for spills.
-            If we notice an input-reload insn here, we will reject it below,
-            but it might hide a usable equivalent.  That makes bad code.
-            It may even abort: perhaps no reg was spilled for this insn
-            because it was assumed we would find that equivalent.  */
+             /* ... then ignore insns introduced by reload; they aren't
+                useful and can cause results in reload_as_needed to be
+                different from what they were when calculating the need for
+                spills.  If we notice an input-reload insn here, we will
+                reject it below, but it might hide a usable equivalent.
+                That makes bad code.  It may even abort: perhaps no reg was
+                spilled for this insn because it was assumed we would find
+                that equivalent.  */
              || INSN_UID (p) < reload_first_uid))
        {
          rtx tem;
          pat = single_set (p);
+
          /* First check for something that sets some reg equal to GOAL.  */
          if (pat != 0
              && ((regno >= 0
@@ -6073,27 +6165,30 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
                  /* If we are looking for a constant,
                     and something equivalent to that constant was copied
                     into a reg, we can use that reg.  */
-                 || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
-                                                         NULL_RTX))
-                     && rtx_equal_p (XEXP (tem, 0), goal)
-                     && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
-                 || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
-                                                         NULL_RTX))
-                     && GET_CODE (SET_DEST (pat)) == REG
-                     && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
-                     && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
-                     && GET_CODE (goal) == CONST_INT
-                     && 0 != (goaltry = operand_subword (XEXP (tem, 0), 0, 0,
+                 || (goal_const && REG_NOTES (p) != 0
+                     && (tem = find_reg_note (p, REG_EQUIV, NULL_RTX))
+                     && ((rtx_equal_p (XEXP (tem, 0), goal)
+                          && (valueno
+                              = true_regnum (valtry = SET_DEST (pat))) >= 0)
+                         || (GET_CODE (SET_DEST (pat)) == REG
+                             && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
+                             && (GET_MODE_CLASS (GET_MODE (XEXP (tem, 0)))
+                                 == MODE_FLOAT)
+                             && GET_CODE (goal) == CONST_INT
+                             && 0 != (goaltry
+                                      = operand_subword (XEXP (tem, 0), 0, 0,
                                                          VOIDmode))
-                     && rtx_equal_p (goal, goaltry)
-                     && (valtry = operand_subword (SET_DEST (pat), 0, 0,
-                                                   VOIDmode))
-                     && (valueno = true_regnum (valtry)) >= 0)
+                             && rtx_equal_p (goal, goaltry)
+                             && (valtry
+                                 = operand_subword (SET_DEST (pat), 0, 0,
+                                                    VOIDmode))
+                             && (valueno = true_regnum (valtry)) >= 0)))
                  || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
                                                          NULL_RTX))
                      && GET_CODE (SET_DEST (pat)) == REG
                      && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
-                     && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
+                     && (GET_MODE_CLASS (GET_MODE (XEXP (tem, 0)))
+                         == MODE_FLOAT)
                      && GET_CODE (goal) == CONST_INT
                      && 0 != (goaltry = operand_subword (XEXP (tem, 0), 1, 0,
                                                          VOIDmode))
@@ -6101,16 +6196,29 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
                      && (valtry
                          = operand_subword (SET_DEST (pat), 1, 0, VOIDmode))
                      && (valueno = true_regnum (valtry)) >= 0)))
-           if (other >= 0
-               ? valueno == other
-               : ((unsigned) valueno < FIRST_PSEUDO_REGISTER
-                  && TEST_HARD_REG_BIT (reg_class_contents[(int) class],
-                                        valueno)))
-             {
-               value = valtry;
-               where = p;
-               break;
-             }
+           {
+             if (other >= 0)
+               {
+                 if (valueno != other)
+                   continue;
+               }
+             else if ((unsigned) valueno >= FIRST_PSEUDO_REGISTER)
+               continue;
+             else
+               {
+                 int i;
+
+                 for (i = HARD_REGNO_NREGS (valueno, mode) - 1; i >= 0; i--)
+                   if (! TEST_HARD_REG_BIT (reg_class_contents[(int) class],
+                                            valueno + i))
+                     break;
+                 if (i >= 0)
+                   continue;
+               }
+             value = valtry;
+             where = p;
+             break;
+           }
        }
     }
 
@@ -6122,7 +6230,7 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
 
   /* Don't try to re-use something that is killed in this insn.  We want
      to be able to trust REG_UNUSED notes.  */
-  if (find_reg_note (where, REG_UNUSED, value))
+  if (REG_NOTES (where) != 0 && find_reg_note (where, REG_UNUSED, value))
     return 0;
 
   /* If we propose to get the value from the stack pointer or if GOAL is
@@ -6149,30 +6257,26 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
   /* Reject registers that overlap GOAL.  */
 
   if (!goal_mem && !goal_const
-      && regno + HARD_REGNO_NREGS (regno, mode) > valueno
-      && regno < valueno + HARD_REGNO_NREGS (valueno, mode))
+      && regno + (int) HARD_REGNO_NREGS (regno, mode) > valueno
+      && regno < valueno + (int) HARD_REGNO_NREGS (valueno, mode))
     return 0;
 
+  nregs = HARD_REGNO_NREGS (regno, mode);
+  valuenregs = HARD_REGNO_NREGS (valueno, mode);
+
   /* Reject VALUE if it is one of the regs reserved for reloads.
      Reload1 knows how to reuse them anyway, and it would get
      confused if we allocated one without its knowledge.
      (Now that insns introduced by reload are ignored above,
      this case shouldn't happen, but I'm not positive.)  */
 
-  if (reload_reg_p != 0 && reload_reg_p != (short *) (HOST_WIDE_INT) 1
-      && reload_reg_p[valueno] >= 0)
-    return 0;
-
-  /* On some machines, certain regs must always be rejected
-     because they don't behave the way ordinary registers do.  */
-  
-#ifdef OVERLAPPING_REGNO_P
-  if (OVERLAPPING_REGNO_P (valueno))
-    return 0;
-#endif      
-
-  nregs = HARD_REGNO_NREGS (regno, mode);
-  valuenregs = HARD_REGNO_NREGS (valueno, mode);
+  if (reload_reg_p != 0 && reload_reg_p != (short *) (HOST_WIDE_INT) 1)
+    {
+      int i;
+      for (i = 0; i < valuenregs; ++i)
+       if (reload_reg_p[valueno + i] >= 0)
+         return 0;
+    }
 
   /* Reject VALUE if it is a register being used for an input reload
      even if it is not one of those reserved.  */
@@ -6181,11 +6285,11 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
     {
       int i;
       for (i = 0; i < n_reloads; i++)
-       if (reload_reg_rtx[i] != 0 && reload_in[i])
+       if (rld[i].reg_rtx != 0 && rld[i].in)
          {
-           int regno1 = REGNO (reload_reg_rtx[i]);
+           int regno1 = REGNO (rld[i].reg_rtx);
            int nregs1 = HARD_REGNO_NREGS (regno1,
-                                          GET_MODE (reload_reg_rtx[i]));
+                                          GET_MODE (rld[i].reg_rtx));
            if (regno1 < valueno + valuenregs
                && regno1 + nregs1 > valueno)
              return 0;
@@ -6209,37 +6313,36 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
 
       /* Don't trust the conversion past a function call
         if either of the two is in a call-clobbered register, or memory.  */
-      if (GET_CODE (p) == CALL_INSN
-         && ((regno >= 0 && regno < FIRST_PSEUDO_REGISTER
-              && call_used_regs[regno])
-             ||
-             (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
-              && call_used_regs[valueno])
-             ||
-             goal_mem
-             || need_stable_sp))
-       return 0;
+      if (GET_CODE (p) == CALL_INSN)
+       {
+         int i;
+
+         if (goal_mem || need_stable_sp)
+           return 0;
 
-#ifdef NON_SAVING_SETJMP 
+         if (regno >= 0 && regno < FIRST_PSEUDO_REGISTER)
+           for (i = 0; i < nregs; ++i)
+             if (call_used_regs[regno + i])
+               return 0;
+
+         if (valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER)
+           for (i = 0; i < valuenregs; ++i)
+             if (call_used_regs[valueno + i])
+               return 0;
+       }
+
+#ifdef NON_SAVING_SETJMP
       if (NON_SAVING_SETJMP && GET_CODE (p) == NOTE
          && NOTE_LINE_NUMBER (p) == NOTE_INSN_SETJMP)
        return 0;
 #endif
 
-#ifdef INSN_CLOBBERS_REGNO_P
-      if ((valueno >= 0 && valueno < FIRST_PSEUDO_REGISTER
-         && INSN_CLOBBERS_REGNO_P (p, valueno))
-         || (regno >= 0 && regno < FIRST_PSEUDO_REGISTER
-         && INSN_CLOBBERS_REGNO_P (p, regno)))
-       return 0;
-#endif
-
-      if (GET_RTX_CLASS (GET_CODE (p)) == 'i')
+      if (INSN_P (p))
        {
          pat = PATTERN (p);
 
-          /* Watch out for unspec_volatile, and volatile asms.  */
-          if (volatile_insn_p (pat))
+         /* Watch out for unspec_volatile, and volatile asms.  */
+         if (volatile_insn_p (pat))
            return 0;
 
          /* If this insn P stores in either GOAL or VALUE, return 0.
@@ -6247,6 +6350,8 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
             If GOAL is a memory ref and its address is not constant,
             and this insn P changes a register used in GOAL, return 0.  */
 
+         if (GET_CODE (pat) == COND_EXEC)
+           pat = COND_EXEC_CODE (pat);
          if (GET_CODE (pat) == SET || GET_CODE (pat) == CLOBBER)
            {
              register rtx dest = SET_DEST (pat);
@@ -6289,6 +6394,8 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
              for (i = XVECLEN (pat, 0) - 1; i >= 0; i--)
                {
                  register rtx v1 = XVECEXP (pat, 0, i);
+                 if (GET_CODE (v1) == COND_EXEC)
+                   v1 = COND_EXEC_CODE (v1);
                  if (GET_CODE (v1) == SET || GET_CODE (v1) == CLOBBER)
                    {
                      register rtx dest = SET_DEST (v1);
@@ -6342,30 +6449,25 @@ find_equiv_reg (goal, insn, class, other, reload_reg_p, goalreg, mode)
                  if (GET_CODE (pat) == CLOBBER)
                    {
                      register rtx dest = SET_DEST (pat);
-                     while (GET_CODE (dest) == SUBREG
-                            || GET_CODE (dest) == ZERO_EXTRACT
-                            || GET_CODE (dest) == SIGN_EXTRACT
-                            || GET_CODE (dest) == STRICT_LOW_PART)
-                       dest = XEXP (dest, 0);
+
                      if (GET_CODE (dest) == REG)
                        {
                          register int xregno = REGNO (dest);
-                         int xnregs;
-                         if (REGNO (dest) < FIRST_PSEUDO_REGISTER)
-                           xnregs = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
-                         else
-                           xnregs = 1;
+                         int xnregs
+                           = HARD_REGNO_NREGS (xregno, GET_MODE (dest));
+
                          if (xregno < regno + nregs
                              && xregno + xnregs > regno)
                            return 0;
-                         if (xregno < valueno + valuenregs
-                             && xregno + xnregs > valueno)
+                         else if (xregno < valueno + valuenregs
+                                  && xregno + xnregs > valueno)
                            return 0;
-                         if (goal_mem_addr_varies
-                             && reg_overlap_mentioned_for_reload_p (dest,
+                         else if (goal_mem_addr_varies
+                                  && reg_overlap_mentioned_for_reload_p (dest,
                                                                     goal))
                            return 0;
                        }
+
                      else if (goal_mem && GET_CODE (dest) == MEM
                               && ! push_operand (dest, GET_MODE (dest)))
                        return 0;
@@ -6413,7 +6515,7 @@ find_inc_amount (x, inced)
      rtx x, inced;
 {
   register enum rtx_code code = GET_CODE (x);
-  register char *fmt;
+  register const char *fmt;
   register int i;
 
   if (code == MEM)
@@ -6425,6 +6527,16 @@ find_inc_amount (x, inced)
           || GET_CODE (addr) == POST_INC)
          && XEXP (addr, 0) == inced)
        return GET_MODE_SIZE (GET_MODE (x));
+      else if ((GET_CODE (addr) == PRE_MODIFY
+               || GET_CODE (addr) == POST_MODIFY)
+              && GET_CODE (XEXP (addr, 1)) == PLUS
+              && XEXP (addr, 0) == XEXP (XEXP (addr, 1), 0)
+              && XEXP (addr, 0) == inced
+              && GET_CODE (XEXP (XEXP (addr, 1), 1)) == CONST_INT)
+       {
+         i = INTVAL (XEXP (XEXP (addr, 1), 1));
+         return i < 0 ? -i : i;
+       }
     }
 
   fmt = GET_RTX_FORMAT (code);
@@ -6451,16 +6563,27 @@ find_inc_amount (x, inced)
   return 0;
 }
 \f
-/* Return 1 if register REGNO is the subject of a clobber in insn INSN.  */
+/* Return 1 if register REGNO is the subject of a clobber in insn INSN.
+   If SETS is nonzero, also consider SETs.  */
 
 int
-regno_clobbered_p (regno, insn)
-     int regno;
+regno_clobbered_p (regno, insn, mode, sets)
+     unsigned int regno;
      rtx insn;
+     enum machine_mode mode;
+     int sets;
 {
-  if (GET_CODE (PATTERN (insn)) == CLOBBER
+  int nregs = HARD_REGNO_NREGS (regno, mode);
+  int endregno = regno + nregs;
+
+  if ((GET_CODE (PATTERN (insn)) == CLOBBER
+       || (sets && GET_CODE (PATTERN (insn)) == SET))
       && GET_CODE (XEXP (PATTERN (insn), 0)) == REG)
-    return REGNO (XEXP (PATTERN (insn), 0)) == regno;
+    {
+      int test = REGNO (XEXP (PATTERN (insn), 0));
+
+      return test >= regno && test < endregno;
+    }
 
   if (GET_CODE (PATTERN (insn)) == PARALLEL)
     {
@@ -6469,31 +6592,37 @@ regno_clobbered_p (regno, insn)
       for (; i >= 0; i--)
        {
          rtx elt = XVECEXP (PATTERN (insn), 0, i);
-         if (GET_CODE (elt) == CLOBBER && GET_CODE (XEXP (elt, 0)) == REG
-             && REGNO (XEXP (elt, 0)) == regno)
-           return 1;
+         if ((GET_CODE (elt) == CLOBBER
+              || (sets && GET_CODE (PATTERN (insn)) == SET))
+             && GET_CODE (XEXP (elt, 0)) == REG)
+           {
+             int test = REGNO (XEXP (elt, 0));
+             
+             if (test >= regno && test < endregno)
+               return 1;
+           }
        }
     }
 
   return 0;
 }
 
-static char *reload_when_needed_name[] =
+static const char *reload_when_needed_name[] =
 {
-  "RELOAD_FOR_INPUT", 
-  "RELOAD_FOR_OUTPUT", 
+  "RELOAD_FOR_INPUT",
+  "RELOAD_FOR_OUTPUT",
   "RELOAD_FOR_INSN",
   "RELOAD_FOR_INPUT_ADDRESS",
   "RELOAD_FOR_INPADDR_ADDRESS",
   "RELOAD_FOR_OUTPUT_ADDRESS",
   "RELOAD_FOR_OUTADDR_ADDRESS",
-  "RELOAD_FOR_OPERAND_ADDRESS", 
+  "RELOAD_FOR_OPERAND_ADDRESS",
   "RELOAD_FOR_OPADDR_ADDR",
-  "RELOAD_OTHER", 
+  "RELOAD_OTHER",
   "RELOAD_FOR_OTHER_ADDRESS"
 };
 
-static char *reg_class_names[] = REG_CLASS_NAMES;
+static const char * const reg_class_names[] = REG_CLASS_NAMES;
 
 /* These functions are used to print the variables set by 'find_reloads' */
 
@@ -6502,7 +6631,7 @@ debug_reload_to_stream (f)
      FILE *f;
 {
   int r;
-  char *prefix;
+  const char *prefix;
 
   if (! f)
     f = stderr;
@@ -6510,84 +6639,84 @@ debug_reload_to_stream (f)
     {
       fprintf (f, "Reload %d: ", r);
 
-      if (reload_in[r] != 0)
+      if (rld[r].in != 0)
        {
          fprintf (f, "reload_in (%s) = ",
-                  GET_MODE_NAME (reload_inmode[r]));
-         print_inline_rtx (f, reload_in[r], 24);
+                  GET_MODE_NAME (rld[r].inmode));
+         print_inline_rtx (f, rld[r].in, 24);
          fprintf (f, "\n\t");
        }
 
-      if (reload_out[r] != 0)
+      if (rld[r].out != 0)
        {
          fprintf (f, "reload_out (%s) = ",
-                  GET_MODE_NAME (reload_outmode[r]));
-         print_inline_rtx (f, reload_out[r], 24);
+                  GET_MODE_NAME (rld[r].outmode));
+         print_inline_rtx (f, rld[r].out, 24);
          fprintf (f, "\n\t");
        }
 
-      fprintf (f, "%s, ", reg_class_names[(int) reload_reg_class[r]]);
+      fprintf (f, "%s, ", reg_class_names[(int) rld[r].class]);
 
       fprintf (f, "%s (opnum = %d)",
-              reload_when_needed_name[(int) reload_when_needed[r]],
-              reload_opnum[r]);
+              reload_when_needed_name[(int) rld[r].when_needed],
+              rld[r].opnum);
 
-      if (reload_optional[r])
+      if (rld[r].optional)
        fprintf (f, ", optional");
 
-      if (reload_nongroup[r])
-       fprintf (stderr, ", nongroup");
+      if (rld[r].nongroup)
+       fprintf (f, ", nongroup");
 
-      if (reload_inc[r] != 0)
-       fprintf (f, ", inc by %d", reload_inc[r]);
+      if (rld[r].inc != 0)
+       fprintf (f, ", inc by %d", rld[r].inc);
 
-      if (reload_nocombine[r])
+      if (rld[r].nocombine)
        fprintf (f, ", can't combine");
 
-      if (reload_secondary_p[r])
+      if (rld[r].secondary_p)
        fprintf (f, ", secondary_reload_p");
 
-      if (reload_in_reg[r] != 0)
+      if (rld[r].in_reg != 0)
        {
          fprintf (f, "\n\treload_in_reg: ");
-         print_inline_rtx (f, reload_in_reg[r], 24);
+         print_inline_rtx (f, rld[r].in_reg, 24);
        }
 
-      if (reload_out_reg[r] != 0)
+      if (rld[r].out_reg != 0)
        {
          fprintf (f, "\n\treload_out_reg: ");
-         print_inline_rtx (f, reload_out_reg[r], 24);
+         print_inline_rtx (f, rld[r].out_reg, 24);
        }
 
-      if (reload_reg_rtx[r] != 0)
+      if (rld[r].reg_rtx != 0)
        {
          fprintf (f, "\n\treload_reg_rtx: ");
-         print_inline_rtx (f, reload_reg_rtx[r], 24);
+         print_inline_rtx (f, rld[r].reg_rtx, 24);
        }
 
       prefix = "\n\t";
-      if (reload_secondary_in_reload[r] != -1)
+      if (rld[r].secondary_in_reload != -1)
        {
          fprintf (f, "%ssecondary_in_reload = %d",
-                  prefix, reload_secondary_in_reload[r]);
+                  prefix, rld[r].secondary_in_reload);
          prefix = ", ";
        }
 
-      if (reload_secondary_out_reload[r] != -1)
+      if (rld[r].secondary_out_reload != -1)
        fprintf (f, "%ssecondary_out_reload = %d\n",
-                prefix, reload_secondary_out_reload[r]);
+                prefix, rld[r].secondary_out_reload);
 
       prefix = "\n\t";
-      if (reload_secondary_in_icode[r] != CODE_FOR_nothing)
+      if (rld[r].secondary_in_icode != CODE_FOR_nothing)
        {
-         fprintf (stderr, "%ssecondary_in_icode = %s", prefix,
-                  insn_name[reload_secondary_in_icode[r]]);
+         fprintf (f, "%ssecondary_in_icode = %s", prefix,
+                  insn_data[rld[r].secondary_in_icode].name);
          prefix = ", ";
        }
 
-      if (reload_secondary_out_icode[r] != CODE_FOR_nothing)
-       fprintf (stderr, "%ssecondary_out_icode = %s", prefix,
-                insn_name[reload_secondary_out_icode[r]]);
+      if (rld[r].secondary_out_icode != CODE_FOR_nothing)
+       fprintf (f, "%ssecondary_out_icode = %s", prefix,
+                insn_data[rld[r].secondary_out_icode].name);
 
       fprintf (f, "\n");
     }