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]

[PATCH]: Optimization of X<->Y register move on HC11


Hi!

For a (set (reg x) (reg y)) it is faster to use the sequence 'xgdy; xgdx'
when both 'y' and 'd' are dead (a kind of 3-reg rotation).  Likewise for
(set (reg y) (reg x)) with the sequence 'xgdx; xgdy'.

This patch implements this optimization.  I've committed it on mainline
and 3_0-branch.

	Stephane

2001-05-05  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* config/m68hc11/m68hc11.c (m68hc11_gen_movhi): Optimize moves
	between X and Y by using sequences of xgdx and xgdy.
Index: config/m68hc11/m68hc11.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/m68hc11/m68hc11.c,v
retrieving revision 1.9
diff -u -p -r1.9 m68hc11.c
--- m68hc11.c	2001/05/04 21:00:37	1.9
+++ m68hc11.c	2001/05/05 06:46:53
@@ -3135,8 +3135,20 @@ m68hc11_gen_movhi (insn, operands)
 	    }
 	  else if (Y_REG_P (operands[1]))
 	    {
-	      output_asm_insn ("sty\t%t1", operands);
-	      output_asm_insn ("ldx\t%t1", operands);
+              /* When both D and Y are dead, use the sequence xgdy, xgdx
+                 to move Y into X.  The D and Y registers are modified.  */
+              if (optimize && find_regno_note (insn, REG_DEAD, HARD_Y_REGNUM)
+                  && dead_register_here (insn, d_reg))
+                {
+                  output_asm_insn ("xgdy", operands);
+                  output_asm_insn ("xgdx", operands);
+                  CC_STATUS_INIT;
+                }
+              else
+                {
+                  output_asm_insn ("sty\t%t1", operands);
+                  output_asm_insn ("ldx\t%t1", operands);
+                }
 	    }
 	  else if (SP_REG_P (operands[1]))
 	    {
@@ -3165,8 +3177,20 @@ m68hc11_gen_movhi (insn, operands)
 	    }
 	  else if (X_REG_P (operands[1]))
 	    {
-	      output_asm_insn ("stx\t%t1", operands);
-	      output_asm_insn ("ldy\t%t1", operands);
+              /* When both D and X are dead, use the sequence xgdx, xgdy
+                 to move X into Y.  The D and X registers are modified.  */
+              if (optimize && find_regno_note (insn, REG_DEAD, HARD_X_REGNUM)
+                  && dead_register_here (insn, d_reg))
+                {
+                  output_asm_insn ("xgdx", operands);
+                  output_asm_insn ("xgdy", operands);
+                  CC_STATUS_INIT;
+                }
+              else
+                {
+                  output_asm_insn ("stx\t%t1", operands);
+                  output_asm_insn ("ldy\t%t1", operands);
+                }
 	    }
 	  else if (SP_REG_P (operands[1]))
 	    {

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