This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
S/390: Adjust cost macros
- From: "Ulrich Weigand" <Ulrich dot Weigand at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Sep 2002 21:00:43 +0200
- Subject: S/390: Adjust cost macros
- Sensitivity:
Hello,
this fixes the s390 ADDRESS_COST and RTX_COST to properly use
COSTS_N_INSNS. Also, the new ADDRESS_COST is slightly biased
against two-register addresses as those might require a Q constraint
reload later on.
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux.
ChangeLog:
* config/s390/s390.c (s390_address_cost): New function.
config/s390/s390-protos.h (s390_address_cost): Add prototype.
config/s390/s390.h (ADDRESS_COST): Call s390_address_cost.
(RTX_COST): Use COSTS_N_INSNS.
Index: gcc/config/s390/s390-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390-protos.h,v
retrieving revision 1.13
diff -c -p -r1.13 s390-protos.h
*** gcc/config/s390/s390-protos.h 16 Sep 2002 14:13:12 -0000 1.13
--- gcc/config/s390/s390-protos.h 18 Sep 2002 16:35:55 -0000
*************** extern void s390_emit_epilogue PARAMS ((
*** 29,34 ****
--- 29,35 ----
extern void s390_function_profiler PARAMS ((FILE *, int));
#ifdef RTX_CODE
+ extern int s390_address_cost PARAMS ((rtx));
extern int q_constraint PARAMS ((rtx));
extern int const0_operand PARAMS ((rtx, enum machine_mode));
extern int consttable_operand PARAMS ((rtx, enum machine_mode));
Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.52
diff -c -p -r1.52 s390.c
*** gcc/config/s390/s390.c 16 Sep 2002 14:13:12 -0000 1.52
--- gcc/config/s390/s390.c 18 Sep 2002 16:35:59 -0000
*************** q_constraint (op)
*** 1050,1055 ****
--- 1050,1068 ----
return 1;
}
+ /* Return the cost of an address rtx ADDR. */
+
+ int
+ s390_address_cost (addr)
+ rtx addr;
+ {
+ struct s390_address ad;
+ if (!s390_decompose_address (addr, &ad))
+ return 1000;
+
+ return ad.indx? COSTS_N_INSNS (1) + 1 : COSTS_N_INSNS (1);
+ }
+
/* Return true if OP is a valid operand for the BRAS instruction.
OP is the current operation.
MODE is the current operation mode. */
Index: gcc/config/s390/s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.42
diff -c -p -r1.42 s390.h
*** gcc/config/s390/s390.h 10 Sep 2002 18:46:06 -0000 1.42
--- gcc/config/s390/s390.h 18 Sep 2002 16:36:01 -0000
*************** CUMULATIVE_ARGS;
*** 1145,1161 ****
case MINUS: \
case NEG: \
case NOT: \
! return 1; \
case MULT: \
if (GET_MODE (XEXP (X, 0)) == DImode) \
! return 40; \
! else \
! return 7; \
case DIV: \
case UDIV: \
case MOD: \
case UMOD: \
! return 33;
/* An expression giving the cost of an addressing mode that contains
--- 1145,1161 ----
case MINUS: \
case NEG: \
case NOT: \
! return COSTS_N_INSNS (1); \
case MULT: \
if (GET_MODE (XEXP (X, 0)) == DImode) \
! return COSTS_N_INSNS (40); \
! else \
! return COSTS_N_INSNS (7); \
case DIV: \
case UDIV: \
case MOD: \
case UMOD: \
! return COSTS_N_INSNS (33);
/* An expression giving the cost of an addressing mode that contains
*************** CUMULATIVE_ARGS;
*** 1197,1209 ****
of registers on machines with lots of registers.
This macro will normally either not be defined or be defined as a
! constant.
! On s390 symbols are expensive if compiled with fpic
! lifetimes. */
!
! #define ADDRESS_COST(RTX) \
! ((flag_pic && GET_CODE (RTX) == SYMBOL_REF) ? 2 : 1)
/* On s390, copy between fprs and gprs is expensive. */
--- 1197,1205 ----
of registers on machines with lots of registers.
This macro will normally either not be defined or be defined as a
! constant. */
! #define ADDRESS_COST(RTX) s390_address_cost ((RTX))
/* On s390, copy between fprs and gprs is expensive. */
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