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: Optimize one case of zero_extract.


Hi,

Attached is a patch to optimize one case of zero_extract.
Specifically, the patch optimizes

(set (reg:SI X)
     (zero_extract:SI (reg:SI Y)
		      (const_int 8)
		      (const_int 8)))

Currently, the corresponding assembly code is

 	mov.b	r3h,r0l
	extu.w	r0
	extu.l	er0

but this can be optimized to 

	sub.l	er0,er0
 	mov.b	r3h,r0l

if X and Y are different registers.

Tested on h8300 port.  Committed.

Kazu Hirata

2003-03-03  Kazu Hirata  <kazu at cs dot umass dot edu>

	* config/h8300/h8300.md (*extzv_8_8): Use shorter code when
	operands[0] and operands[1] are different.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.180
diff -u -r1.180 h8300.md
--- h8300.md	2 Mar 2003 19:12:45 -0000	1.180
+++ h8300.md	3 Mar 2003 12:30:50 -0000
@@ -2630,7 +2630,14 @@
 			 (const_int 8)
 			 (const_int 8)))]
   "TARGET_H8300H || TARGET_H8300S"
-  "mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0"
+  "*
+{
+  if (REG_P (operands[0]) && REG_P (operands[1])
+      && REGNO (operands[0]) != REGNO (operands[1]))
+    return \"sub.l\\t%S0,%S0\;mov.b\\t%x1,%w0\";
+  else
+    return \"mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0\";
+}"
   [(set_attr "cc" "set_znv")
    (set_attr "length" "6")])
 


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