This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Fix HC11/HC12 costs
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH]: Fix HC11/HC12 costs
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Fri, 04 May 2001 20:21:47 +0200
Hi!
There are few problems with HC11/H12 costs:
- multiplication by 65536 are preferred over shift by 16
- shift by 16 and 32 appear more expensive than the generated move
- addition of the same register is preferred over a shift by 1 (but adding
a register to itself is not supported by the microcontrollers)
- the reload-cse pass replaces constant operands by a register combined
with an add because 'rtx_cost(x, PLUS) < rtx_cost(x, SET)' when x is
a constant.
This patch fixes these problems. I've committed it in mainline and 3_0-branch.
Stephane
2001-05-04 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/m68hc11/m68hc11.h (CONST_COSTS): Make the cost of
constants cheap after reload.
* config/m68hc11/m68hc11.c (m68hc11_shift_cost): Shift by 16 and 32
are cheap.
(m68hc11_rtx_costs): Cost of multiplication by 65536 is expensive
so that gcc prefers a shift by 16.
(m6811_cost, m6812_cost): Make the shift cheap compared to an add.
Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.7
diff -u -p -r1.7 m68hc11.c
--- m68hc11.c 2001/05/03 20:52:42 1.7
+++ m68hc11.c 2001/05/04 18:05:05
@@ -136,7 +136,7 @@ struct processor_costs m6811_cost = {
COSTS_N_INSNS (2), COSTS_N_INSNS (1) },
/* shiftHI const */
- { COSTS_N_INSNS (0), COSTS_N_INSNS (2), COSTS_N_INSNS (4),
+ { COSTS_N_INSNS (0), COSTS_N_INSNS (1), COSTS_N_INSNS (4),
COSTS_N_INSNS (6), COSTS_N_INSNS (8), COSTS_N_INSNS (6),
COSTS_N_INSNS (4), COSTS_N_INSNS (2),
COSTS_N_INSNS (2), COSTS_N_INSNS (4),
@@ -171,7 +171,7 @@ struct processor_costs m6812_cost = {
COSTS_N_INSNS (2), COSTS_N_INSNS (1) },
/* shiftHI const */
- { COSTS_N_INSNS (0), COSTS_N_INSNS (2), COSTS_N_INSNS (4),
+ { COSTS_N_INSNS (0), COSTS_N_INSNS (1), COSTS_N_INSNS (4),
COSTS_N_INSNS (6), COSTS_N_INSNS (8), COSTS_N_INSNS (6),
COSTS_N_INSNS (4), COSTS_N_INSNS (2),
COSTS_N_INSNS (2), COSTS_N_INSNS (4), COSTS_N_INSNS (6),
@@ -4975,7 +4975,7 @@ m68hc11_shift_cost (mode, x, shift)
}
/* For SI and others, the cost is higher. */
- if (GET_MODE_SIZE (mode) > 2)
+ if (GET_MODE_SIZE (mode) > 2 && (shift % 16) != 0)
total *= GET_MODE_SIZE (mode) / 2;
/* When optimizing for size, make shift more costly so that
@@ -5081,10 +5081,6 @@ m68hc11_rtx_costs (x, code, outer_code)
break;
case SImode:
- if (GET_CODE (XEXP (x, 1)) == CONST_INT
- && INTVAL (XEXP (x, 1)) == 65536)
- break;
-
default:
total += m68hc11_cost->multSI;
break;
Index: config/m68hc11/m68hc11.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/m68hc11.h,v
retrieving revision 1.8
diff -u -p -r1.8 m68hc11.h
--- m68hc11.h 2001/05/04 15:06:35 1.8
+++ m68hc11.h 2001/05/04 18:05:16
@@ -1481,14 +1481,16 @@ extern unsigned char m68hc11_reg_valid_f
/* with two registers. */ \
/* 'clr' is slow */ \
if ((OUTER_CODE) == SET && (RTX) == const0_rtx) \
- return 1; \
+ /* After reload, the reload_cse pass checks the cost */ \
+ /* to change a SET into a PLUS. Make const0 cheap. */ \
+ return 1 - reload_completed; \
else \
return 0; \
case CONST: \
case LABEL_REF: \
case SYMBOL_REF: \
if ((OUTER_CODE) == SET) \
- return 1; \
+ return 1 - reload_completed; \
return 0; \
case CONST_DOUBLE: \
return 0;