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]

S/390: Fix minor missed optimization


Hello,

we sometimes use (arg pointer - constant) as address, but this is rejected
by s390_decompose_address due to the out-of-range displacement.

However, after arg pointer elimination these addresses usually become
valid.  This patch changes s390_decompose_address to acknowledge that.

Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.

ChangeLog:

      * config/s390/s390.c (s390_decompose_address): Do not range check the
      displacement if base or index is the argument pointer register.


Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.65
diff -c -p -r1.65 s390.c
*** gcc/config/s390/s390.c    23 Oct 2002 16:32:43 -0000    1.65
--- gcc/config/s390/s390.c    24 Oct 2002 22:00:07 -0000
*************** s390_decompose_address (addr, out)
*** 1597,1604 ****
        /* Allow integer constant in range.  */
        if (GET_CODE (disp) == CONST_INT)
          {
!           if (INTVAL (disp) < 0 || INTVAL (disp) >= 4096)
!               return FALSE;
          }

        /* In the small-PIC case, the linker converts @GOT12
--- 1597,1616 ----
        /* Allow integer constant in range.  */
        if (GET_CODE (disp) == CONST_INT)
          {
!       /* If the argument pointer is involved, the displacement will change
!          later anyway as the argument pointer gets eliminated.  This could
!          make a valid displacement invalid, but it is more likely to make
!          an invalid displacement valid, because we sometimes access the
!          register save area via negative offsets to the arg pointer.
!          Thus we don't check the displacement for validity here.  If after
!          elimination the displacement turns out to be invalid after all,
!          this is fixed up by reload in any case.  */
!       if ((base && REGNO (base) == ARG_POINTER_REGNUM)
!           || (indx && REGNO (indx) == ARG_POINTER_REGNUM))
!         ;
!
!       else if (INTVAL (disp) < 0 || INTVAL (disp) >= 4096)
!         return FALSE;
          }

        /* In the small-PIC case, the linker converts @GOT12

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]