public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* S/390: Fix minor missed optimization
@ 2002-10-25  5:32 Ulrich Weigand
  2002-10-25 13:14 ` Richard Henderson
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2002-10-25  5:32 UTC (permalink / raw)
  To: gcc-patches

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

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: S/390: Fix minor missed optimization
@ 2002-11-04 11:11 Ulrich Weigand
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2002-11-04 11:11 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches


Richard Henderson wrote:

>Better to compare against the arg_pointer_rtx directly.

Right.  I've committed the following patch to fix this.

Thanks,
Ulrich



      * config/s390/s390.c (s390_decompose_address): Use arg_pointer_rtx
      for comparison.

Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.66
diff -c -p -r1.66 s390.c
*** gcc/config/s390/s390.c    25 Oct 2002 12:26:40 -0000    1.66
--- gcc/config/s390/s390.c    4 Nov 2002 13:24:20 -0000
*************** s390_decompose_address (addr, out)
*** 1605,1616 ****
           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
--- 1605,1615 ----
           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 != arg_pointer_rtx && indx != arg_pointer_rtx)
!         {
!           if (INTVAL (disp) < 0 || INTVAL (disp) >= 4096)
!             return FALSE;
!         }
          }

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-11-04 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-25  5:32 S/390: Fix minor missed optimization Ulrich Weigand
2002-10-25 13:14 ` Richard Henderson
2002-11-04 11:11 Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).