This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] h8300: Make RTX_COSTS compute the costs of shifts.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 27 Nov 2002 17:21:12 -0500 (EST)
- Subject: [patch] h8300: Make RTX_COSTS compute the costs of shifts.
Hi,
Attached is a patch to make RTX_COSTS compute the costs of shifts.
The new function, h8300_shift_costs, computes the cost of a shift insn
as its length.
Tested on h8300 port. Committed.
Kazu Hirata
2002-11-27 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (h8300_shift_costs): New.
* config/h8300/h8300.h (RTX_COSTS): Use h8300_shift_costs.
* config/h8300/h8300-protos.h: Add a prototype for
h8300_shift_costs.
Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.164
diff -u -r1.164 h8300.c
--- h8300.c 27 Nov 2002 03:46:50 -0000 1.164
+++ h8300.c 27 Nov 2002 22:13:57 -0000
@@ -1134,6 +1134,24 @@
return 4;
}
}
+
+int
+h8300_shift_costs (x)
+ rtx x;
+{
+ rtx operands[4];
+
+ if (GET_MODE (x) != QImode
+ && GET_MODE (x) != HImode
+ && GET_MODE (x) != SImode)
+ return 100;
+
+ operands[0] = NULL;
+ operands[1] = NULL;
+ operands[2] = XEXP (x, 1);
+ operands[3] = x;
+ return compute_a_shift_length (NULL, operands);
+}
/* Documentation for the machine specific operand escapes:
Index: h8300.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.h,v
retrieving revision 1.118
diff -u -r1.118 h8300.h
--- h8300.h 27 Nov 2002 03:46:50 -0000 1.118
+++ h8300.h 27 Nov 2002 22:13:58 -0000
@@ -1020,20 +1020,20 @@
/* Provide the costs of a rtl expression. This is in the body of a
switch on CODE. */
-/* ??? Shifts need to have a *much* higher cost than this. */
-#define RTX_COSTS(RTX, CODE, OUTER_CODE) \
- case MOD: \
- case DIV: \
- return 60; \
- case MULT: \
- return 20; \
- case ASHIFT: \
- case ASHIFTRT: \
- case LSHIFTRT: \
- case ROTATE: \
- case ROTATERT: \
- if (GET_MODE (RTX) == HImode) return 2; \
+#define RTX_COSTS(RTX, CODE, OUTER_CODE) \
+ case MOD: \
+ case DIV: \
+ return 60; \
+ case MULT: \
+ return 20; \
+ case ASHIFT: \
+ case ASHIFTRT: \
+ case LSHIFTRT: \
+ return COSTS_N_INSNS (h8300_shift_costs (RTX)); \
+ case ROTATE: \
+ case ROTATERT: \
+ if (GET_MODE (RTX) == HImode) return 2; \
return 8;
/* Tell final.c how to eliminate redundant test instructions. */
Index: h8300-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300-protos.h,v
retrieving revision 1.32
diff -u -r1.32 h8300-protos.h
--- h8300-protos.h 29 Oct 2002 17:55:45 -0000 1.32
+++ h8300-protos.h 27 Nov 2002 22:13:58 -0000
@@ -32,6 +32,7 @@
extern const char *output_simode_bld PARAMS ((int, rtx[]));
extern void print_operand_address PARAMS ((FILE *, rtx));
extern int const_costs PARAMS ((rtx, enum rtx_code, enum rtx_code));
+extern int h8300_shift_costs PARAMS ((rtx));
extern void print_operand PARAMS ((FILE *, rtx, int));
extern void final_prescan_insn PARAMS ((rtx, rtx *, int));
extern int do_movsi PARAMS ((rtx[]));