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] h8300.md: Add a new pattern.


Hi,

Attached is a patch to add a new pattern.  On H8/300H and H8S,

  (A >> 1) | (A & 1)

can be done quite quickly with a carry flag.  In terms of assembly
code, gcc without the patch generates

 	mov.l	er0,er2
 	shlr.l	er0
	bld	#0,r2l
 	bor	#0,r0l
 	bst	#0,r0l

With the patch

 	shlr.l	er0
 	bor	#0,r0l
 	bst	#0,r0l

Tested on h8300 port.  Committed.

Kazu Hirata

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

	* config/h8300/h8300.md (*iorsi2_and_1_lshiftrt_1): New.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.165
diff -u -r1.165 h8300.md
--- h8300.md	13 Feb 2003 16:33:00 -0000	1.165
+++ h8300.md	14 Feb 2003 12:53:36 -0000
@@ -2878,6 +2878,17 @@
 		(match_dup 0)))]
   "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
 
+(define_insn "*iorsi2_and_1_lshiftrt_1"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+	(ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
+			(const_int 1))
+		(lshiftrt:SI (match_dup 1)
+			     (const_int 1))))]
+  "TARGET_H8300H || TARGET_H8300S"
+  "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
+  [(set_attr "length" "6")
+   (set_attr "cc" "clobber")])
+
 ;; Used to add the exponent of a float.
 
 (define_insn "*addsi3_shift"


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