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: optimize loading large displacements


Hello,

this patch adds a minor optimization to the s390 legitimize_address
routine:  by splitting up large displacements into the part that is
a multiple of 4K and the rest, it tries to enable CSE to combine the
former if multiple large displacements are used in sucession (e.g.
by using multiple elements of a large struct).

ChangeLog:

      * config/s390/s390.c (legitimize_address): Optimize loading
      of large displacements.

Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.46
diff -c -p -r1.46 s390.c
*** gcc/config/s390/s390.c    14 Aug 2002 10:04:51 -0000    1.46
--- gcc/config/s390/s390.c    15 Aug 2002 09:47:24 -0000
*************** legitimize_address (x, oldx, mode)
*** 2084,2089 ****
--- 2084,2114 ----

    x = eliminate_constant_term (x, &constant_term);

+   /* Optimize loading of large displacements by splitting them
+      into the multiple of 4K and the rest; this allows the
+      former to be CSE'd if possible.
+
+      Don't do this if the displacement is added to a register
+      pointing into the stack frame, as the offsets will
+      change later anyway.  */
+
+   if (GET_CODE (constant_term) == CONST_INT
+       && (INTVAL (constant_term) < 0
+           || INTVAL (constant_term) >= 4096)
+       && !(REG_P (x) && REGNO_PTR_FRAME_P (REGNO (x))))
+     {
+       HOST_WIDE_INT lower = INTVAL (constant_term) & 0xfff;
+       HOST_WIDE_INT upper = INTVAL (constant_term) ^ lower;
+
+       rtx temp = gen_reg_rtx (Pmode);
+       rtx val  = force_operand (GEN_INT (upper), temp);
+       if (val != temp)
+     emit_move_insn (temp, val);
+
+       x = gen_rtx_PLUS (Pmode, x, temp);
+       constant_term = GEN_INT (lower);
+     }
+
    if (GET_CODE (x) == PLUS)
      {
        if (GET_CODE (XEXP (x, 0)) == REG)


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]