diff mbox

[SH] Simplify zero_extend expanders

Message ID 1341390014.10300.5.camel@yam-132-YW-E178-FTW
State New
Headers show

Commit Message

Oleg Endo July 4, 2012, 8:20 a.m. UTC
Hello,

The attached patch simplifies the SH zero_extend expanders a little.
According to CSiBE it also improves code size a little bit here and
there.

Tested against rev 189081 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
-m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}"

and no new failures.

Cheers,
Oleg

ChangeLog:

	* config/sh/predicates.md (zero_extend_operand): New predicate.
	* config/sh/sh.md (zero_extendhisi2): Simplify by using new
	zero_extend_operand predicate.
	(zero_extendqisi2): Likewise.

Comments

Kaz Kojima July 4, 2012, 10:07 p.m. UTC | #1
Oleg Endo <oleg.endo@t-online.de> wrote:
> The attached patch simplifies the SH zero_extend expanders a little.
> According to CSiBE it also improves code size a little bit here and
> there.

This patch is OK.

Regards,
	kaz
diff mbox

Patch

Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md	(revision 189081)
+++ gcc/config/sh/sh.md	(working copy)
@@ -4700,13 +4700,8 @@ 
 	      (const_string "ignore")))])
 
 (define_expand "zero_extendhisi2"
-  [(set (match_operand:SI 0 "arith_reg_operand" "")
-	(zero_extend:SI (match_operand:HI 1 "general_extend_operand" "")))]
-  ""
-{
-  if (! TARGET_SHMEDIA && ! arith_reg_operand (operands[1], HImode))
-    operands[1] = copy_to_mode_reg (HImode, operands[1]);
-})
+  [(set (match_operand:SI 0 "arith_reg_dest" "")
+	(zero_extend:SI (match_operand:HI 1 "zero_extend_operand" "")))])
 
 (define_insn "*zero_extendhisi2_compact"
   [(set (match_operand:SI 0 "arith_reg_dest" "=r")
@@ -4745,13 +4740,8 @@ 
 })
 
 (define_expand "zero_extendqisi2"
-  [(set (match_operand:SI 0 "arith_reg_operand" "")
-	(zero_extend:SI (match_operand:QI 1 "general_extend_operand" "")))]
-  ""
-{
-  if (! TARGET_SHMEDIA && ! arith_reg_operand (operands[1], QImode))
-    operands[1] = copy_to_mode_reg (QImode, operands[1]);
-})
+  [(set (match_operand:SI 0 "arith_reg_dest" "")
+	(zero_extend:SI (match_operand:QI 1 "zero_extend_operand" "")))])
 
 (define_insn "*zero_extendqisi2_compact"
   [(set (match_operand:SI 0 "arith_reg_dest" "=r")
Index: gcc/config/sh/predicates.md
===================================================================
--- gcc/config/sh/predicates.md	(revision 189081)
+++ gcc/config/sh/predicates.md	(working copy)
@@ -368,6 +368,13 @@ 
 	  : nonimmediate_operand) (op, mode);
 })
 
+;; Returns 1 if the operand can be used in a zero_extend.
+(define_predicate "zero_extend_operand"
+  (ior (and (match_test "TARGET_SHMEDIA")
+	    (match_operand 0 "general_extend_operand"))
+       (and (match_test "! TARGET_SHMEDIA")
+	    (match_operand 0 "arith_reg_operand"))))
+
 ;; Returns 1 if OP can be source of a simple move operation. Same as
 ;; general_operand, but a LABEL_REF is valid, PRE_DEC is invalid as
 ;; are subregs of system registers.