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] RL78 - minor size optimization


Hi,

This patch is a small optimization for the RL78 target that uses the 'clrb' instruction where possible when performing a zero-extend instead of 'mov'ing a literal #0. This saves a byte on each operation.

Regards,

Richard

2014-03-27  Richard Hulme  <peper03@yahoo.com>

	* config/rl78/rl78-real.md (zero_extendqihi2_real):
	Minor optimization to use clrb instruction where possible,
	which is 1 byte shorter than 'mov'ing #0.

---
 gcc/config/rl78/rl78-real.md |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rl78/rl78-real.md b/gcc/config/rl78/rl78-real.md
index 27ff60f..3503a02 100644
--- a/gcc/config/rl78/rl78-real.md
+++ b/gcc/config/rl78/rl78-real.md
@@ -77,12 +77,13 @@
 ;;---------- Conversions ------------------------

 (define_insn "*zero_extendqihi2_real"
-  [(set (match_operand:HI                 0 "nonimmediate_operand" "=rv,A")
-       (zero_extend:HI (match_operand:QI 1 "general_operand" "0,a")))]
+ [(set (match_operand:HI 0 "nonimmediate_operand" "=Bv,DT,A")
+       (zero_extend:HI (match_operand:QI 1 "general_operand" "0,0,a")))]
   "rl78_real_insns_ok ()"
   "@
+   clrb\t%Q0
    mov\t%Q0, #0
-   mov\tx, a \;mov\ta, #0"
+   mov\tx, a \;clrb\ta"
   )

 (define_insn "*extendqihi2_real"
--
1.7.9.5


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