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]

[PATCH]: Fix reg rename optimization on HC11/HC12


Hi!

The reg rename optimization does very bad things on HC11 because the two address
registers X and Y are not equivalent in terms of cost (Y reg needs one more insn byte thus
making the insn larger and slower).  I've added the (undocumented?) HARD_REGNO_RENAME_OK
to tell reg rename about that (and it works great now).

Committed on 3_3 and mainline.

Stephane

2003-03-10 Stephane Carrez <stcarrez at nerim dot fr>

	* config/m68hc11/m68hc11.h (HARD_REGNO_RENAME_OK): Define.
	* config/m68hc11/m68hc11-protos.h (m68hc11_hard_regno_rename_ok):
	Declare.
	* config/m68hc11/m68hc11.c (m68hc11_hard_regno_rename_ok): New function
	for reg rename optimization to avoid using Z and Y registers.
Index: config/m68hc11/m68hc11-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11-protos.h,v
retrieving revision 1.18.14.3
diff -u -p -r1.18.14.3 m68hc11-protos.h
--- config/m68hc11/m68hc11-protos.h	5 Mar 2003 21:34:28 -0000	1.18.14.3
+++ config/m68hc11/m68hc11-protos.h	10 Mar 2003 22:01:52 -0000
@@ -24,6 +24,7 @@ extern int m68hc11_override_options PARA
 extern int m68hc11_optimization_options PARAMS((int,int));
 extern void m68hc11_conditional_register_usage PARAMS((void));
 extern int hard_regno_mode_ok PARAMS((int, enum machine_mode));
+extern int m68hc11_hard_regno_rename_ok PARAMS((int, int));
 
 extern int m68hc11_total_frame_size PARAMS((void));
 extern int m68hc11_initial_frame_pointer_offset PARAMS((void));
Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.56.4.8
diff -u -p -r1.56.4.8 m68hc11.c
--- config/m68hc11/m68hc11.c	10 Mar 2003 21:29:31 -0000	1.56.4.8
+++ config/m68hc11/m68hc11.c	10 Mar 2003 22:01:52 -0000
@@ -384,6 +384,23 @@ hard_regno_mode_ok (regno, mode)
     }
 }
 
+int
+m68hc11_hard_regno_rename_ok (reg1, reg2)
+     int reg1, reg2;
+{
+  /* Don't accept renaming to Z register.  We will replace it to
+     X,Y or D during machine reorg pass.  */
+  if (reg2 == HARD_Z_REGNUM)
+    return 0;
+
+  /* Don't accept renaming D,X to Y register as the code will be bigger.  */
+  if (TARGET_M6811 && reg2 == HARD_Y_REGNUM
+      && (D_REGNO_P (reg1) || X_REGNO_P (reg1)))
+    return 0;
+
+  return 1;
+}
+
 enum reg_class
 preferred_reload_class (operand, class)
      rtx operand;
Index: config/m68hc11/m68hc11.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/m68hc11/m68hc11.h,v
retrieving revision 1.55.4.6
diff -u -p -r1.55.4.6 m68hc11.h
--- config/m68hc11/m68hc11.h	10 Mar 2003 21:51:53 -0000	1.55.4.6
+++ config/m68hc11/m68hc11.h	10 Mar 2003 22:01:53 -0000
@@ -796,6 +796,12 @@ extern enum reg_class m68hc11_tmp_regs_c
 
 #define SMALL_REGISTER_CLASSES 1
 
+/* A C expression that is nonzero if hard register number REGNO2 can be
+   considered for use as a rename register for REGNO1 */
+
+#define HARD_REGNO_RENAME_OK(REGNO1,REGNO2) \
+  m68hc11_hard_regno_rename_ok ((REGNO1), (REGNO2))
+
 /* A C expression whose value is nonzero if pseudos that have been
    assigned to registers of class CLASS would likely be spilled
    because registers of CLASS are needed for spill registers.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]