This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix reload bug w.r.t optional address operand reloads, take 2


Hello,

this is the second attempt to fix the problems related to optional reloads
of address operands.  This patch does not change the behaviour of reload
at all, except in those specific cases where the old behaviour was in fact
incorrect.  In particular, all passes through find_reloads continue to
generate the exact same set of reloads, thereby avoiding the problems caused
by the first attempt.

To find out whether an address operand was already reloaded, I now store
the result of the find_reloads_address calls used for address operands
in a new array 'address_operand_reloaded', similar to the existing array
'address_reloaded'.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux both on
the 3.3 branch and on mainline.  Additionally, bootstrapped/regtested
on i686-pc-linux-gnu (mainline only).

OK for mainline and 3.3?


ChangeLog:

      * reload.c (find_reloads): Do not use the mode specified in the insn
      pattern as reload mode for address operands.  Do not generate optional
      reloads for address operands that were already completely reloaded.


Index: gcc/reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload.c,v
retrieving revision 1.199.2.4
diff -c -p -r1.199.2.4 reload.c
*** gcc/reload.c  1 Feb 2003 17:16:49 -0000     1.199.2.4
--- gcc/reload.c  2 Feb 2003 20:56:30 -0000
*************** find_reloads (insn, replace, ind_levels,
*** 2469,2474 ****
--- 2469,2476 ----
    char pref_or_nothing[MAX_RECOG_OPERANDS];
    /* Nonzero for a MEM operand whose entire address needs a reload.  */
    int address_reloaded[MAX_RECOG_OPERANDS];
+   /* Nonzero for an address operand that needs to be completely reloaded.  */
+   int address_operand_reloaded[MAX_RECOG_OPERANDS];
    /* Value of enum reload_type to use for operand.  */
    enum reload_type operand_type[MAX_RECOG_OPERANDS];
    /* Value of enum reload_type to use within address of operand.  */
*************** find_reloads (insn, replace, ind_levels,
*** 2647,2652 ****
--- 2649,2655 ----
        RTX_CODE code = GET_CODE (recog_data.operand[i]);

        address_reloaded[i] = 0;
+       address_operand_reloaded[i] = 0;
        operand_type[i] = (modified[i] == RELOAD_READ ? RELOAD_FOR_INPUT
                   : modified[i] == RELOAD_WRITE ? RELOAD_FOR_OUTPUT
                   : RELOAD_OTHER);
*************** find_reloads (insn, replace, ind_levels,
*** 2661,2670 ****
        else if (constraints[i][0] == 'p'
             || EXTRA_ADDRESS_CONSTRAINT (constraints[i][0]))
      {
!       find_reloads_address (recog_data.operand_mode[i], (rtx*) 0,
!                       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
           PLUS or MULT, re-recognize and try again.  */
--- 2664,2674 ----
        else if (constraints[i][0] == 'p'
             || EXTRA_ADDRESS_CONSTRAINT (constraints[i][0]))
      {
!       address_operand_reloaded[i]
!         = find_reloads_address (recog_data.operand_mode[i], (rtx*) 0,
!                           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
           PLUS or MULT, re-recognize and try again.  */
*************** find_reloads (insn, replace, ind_levels,
*** 2681,2686 ****
--- 2685,2694 ----

        recog_data.operand[i] = *recog_data.operand_loc[i];
        substed_operand[i] = recog_data.operand[i];
+
+       /* Address operands are reloaded in their existing mode,
+          no matter what is specified in the machine description.  */
+       operand_mode[i] = GET_MODE (recog_data.operand[i]);
      }
        else if (code == MEM)
      {
*************** find_reloads (insn, replace, ind_levels,
*** 3280,3289 ****
                     the address into a base register.  */
                  this_alternative[i] = (int) MODE_BASE_REG_CLASS (VOIDmode);
                  badop = 0;
-
-                 /* Address constraints are reloaded in Pmode, no matter
-                    what mode is given in the machine description.  */
-                 operand_mode[i] = Pmode;
                  break;
                  }

--- 3288,3293 ----
*************** find_reloads (insn, replace, ind_levels,
*** 3853,3858 ****
--- 3857,3863 ----
        }
      else if (goal_alternative_matched[i] < 0
           && goal_alternative_matches[i] < 0
+          && !address_operand_reloaded[i]
           && optimize)
        {
      /* For each non-matching operand that's a MEM or a pseudo-register

Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]