[patch] h8300.md: Optimize stack pushes.

Kazu Hirata kazu@cs.umass.edu
Mon Jul 7 15:46:00 GMT 2003


Hi,

Attached is a patch to optimize stack pushes.

When pushing reg:HI, the original gcc pushes 4 bytes, 2 bytes of
meaningful data and 2 bytes of garbage, to satisfy PUSH_ROUNDING.
However, as far as the hardware is concerned, the stack pointer
address is only required to be a multiple of 2, not 4, so we can push
2 bytes, reg:HI, and then subtract 2 from the stack pointer.

This change won't change the total insn length but saves 2 cycles due
to reduced access to memory.

A similar change applies to QImode pushes.  Note that we have to use
the same code as HImode because we cannot push 1 byte, QImode, as that
leaves the stack pointer odd.

Tested on h8300 port.  Committed.

Kazu Hirata

2003-07-07  Kazu Hirata  <kazu@cs.umass.edu>

	* config/h8300/h8300.md (pushqi1_h8300hs): Optimize by pushing
	2 bytes and then subtract 2 from the stack pointer.
	(pushhi1_h8300hs): Likewise.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.229
diff -u -r1.229 h8300.md
--- h8300.md	6 Jul 2003 23:05:09 -0000	1.229
+++ h8300.md	7 Jul 2003 06:14:12 -0000
@@ -126,7 +126,7 @@
 		   (match_operand:QI 0 "register_operand" "r"))])]
   "(TARGET_H8300H || TARGET_H8300S)
    && REGNO (operands[0]) != SP_REG"
-  "mov.l\\t%S0,@-er7"
+  "mov.w\\t%f0,@-er7\;subs\\t#2,er7"
   [(set_attr "length" "4")
    (set_attr "cc" "clobber")])
 
@@ -218,7 +218,7 @@
 		   (match_operand:HI 0 "register_operand" "r"))])]
   "(TARGET_H8300H || TARGET_H8300S)
    && REGNO (operands[0]) != SP_REG"
-  "mov.l\\t%S0,@-er7"
+  "mov.w\\t%f0,@-er7\;subs\\t#2,er7"
   [(set_attr "length" "4")
    (set_attr "cc" "clobber")])
 



More information about the Gcc-patches mailing list