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: Remove mode from compare.


Hi,

Attached is a patch to remove mode from compare.

Without this patch, compare insns suggested by the combiner are not
recognized at all.  Here are some of my favorite transformations.

1) Remove an unnecessary zero-extension.

-	extu.w	r2
-	cmp.w	#3,r2
+	cmp.b	#3,r2l

2) Don't load a comparison-constant into a register.

-	sub.l	er4,er4
-	add.b	#1,r4l
-	cmp.l	er2,er4
-	bge	.L185
+	cmp.l	#1,er2
+	ble	.L185

3) Reloading becomes quicker.

-	mov.l	@(332,er7),er2
-	and	#0,r2h
-	sub.w	e2,e2
-	xor	#255,r2l
-	mov.l	er2,er2
+	mov.b	@(335,er7),r2l
+	cmp.b	#-1,r2l

Tested on h8300 port.  Committed.

Kazu Hirata

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

	* config/h8300/h8300.md (cmpqi): Remove mode from compare.
	(cmphi): Likewise.
	(*cmphi_h8300): Likewise.
	(*cmphi_h8300hs): Likewise.
	(cmpsi): Likewise.
	(7 peephole2): Likewise.

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.166
diff -u -r1.166 h8300.md
--- h8300.md	14 Feb 2003 16:22:03 -0000	1.166
+++ h8300.md	16 Feb 2003 19:55:24 -0000
@@ -703,8 +703,8 @@
 
 (define_insn "cmpqi"
   [(set (cc0)
-	(compare:QI (match_operand:QI 0 "register_operand" "r")
-		    (match_operand:QI 1 "nonmemory_operand" "rn")))]
+	(compare (match_operand:QI 0 "register_operand" "r")
+		 (match_operand:QI 1 "nonmemory_operand" "rn")))]
   ""
   "cmp.b	%X1,%X0"
   [(set_attr "length" "2")
@@ -712,8 +712,8 @@
 
 (define_expand "cmphi"
   [(set (cc0)
-	(compare:HI (match_operand:HI 0 "register_operand" "")
-		    (match_operand:HI 1 "nonmemory_operand" "")))]
+	(compare (match_operand:HI 0 "register_operand" "")
+		 (match_operand:HI 1 "nonmemory_operand" "")))]
   ""
   "
 {
@@ -723,19 +723,19 @@
     operands[1] = force_reg (HImode, operands[1]);
 }")
 
-(define_insn ""
+(define_insn "*cmphi_h8300"
   [(set (cc0)
-	(compare:HI (match_operand:HI 0 "register_operand" "r")
-		    (match_operand:HI 1 "register_operand" "r")))]
+	(compare (match_operand:HI 0 "register_operand" "r")
+		 (match_operand:HI 1 "register_operand" "r")))]
   "TARGET_H8300"
   "cmp.w	%T1,%T0"
   [(set_attr "length" "2")
    (set_attr "cc" "compare")])
 
-(define_insn ""
+(define_insn "*cmphi_h8300hs"
   [(set (cc0)
-	(compare:HI (match_operand:HI 0 "register_operand" "r,r")
-		    (match_operand:HI 1 "nonmemory_operand" "r,n")))]
+	(compare (match_operand:HI 0 "register_operand" "r,r")
+		 (match_operand:HI 1 "nonmemory_operand" "r,n")))]
   "TARGET_H8300H || TARGET_H8300S"
   "cmp.w	%T1,%T0"
   [(set_attr "length" "2,4")
@@ -743,8 +743,8 @@
 
 (define_insn "cmpsi"
   [(set (cc0)
-	(compare:SI (match_operand:SI 0 "register_operand" "r,r")
-		    (match_operand:SI 1 "nonmemory_operand" "r,i")))]
+	(compare (match_operand:SI 0 "register_operand" "r,r")
+		 (match_operand:SI 1 "nonmemory_operand" "r,i")))]
   "TARGET_H8300H || TARGET_H8300S"
   "cmp.l	%S1,%S0"
   [(set_attr "length" "2,6")
@@ -3446,7 +3446,7 @@
 		      (pc)))]
   "")
 
-;; (compare:SI (reg) (const_int)) takes 6 bytes, so we try to achieve
+;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
 ;; the equivalent with shorter sequences.  Here is the summary.
 ;;
 ;; reg  const_int                 use     insn
@@ -3481,8 +3481,8 @@
 
 (define_peephole2
   [(set (cc0)
-	(compare:HI (match_operand:HI 0 "register_operand" "")
-		    (match_operand:HI 1 "const_int_le_2_operand" "")))
+	(compare (match_operand:HI 0 "register_operand" "")
+		 (match_operand:HI 1 "const_int_le_2_operand" "")))
    (set (pc)
 	(if_then_else (match_operator 3 "eqne_operator"
 			[(cc0) (const_int 0)])
@@ -3503,8 +3503,8 @@
 
 (define_peephole2
   [(set (cc0)
-	(compare:SI (match_operand:SI 0 "register_operand" "")
-		    (match_operand:SI 1 "const_int_le_6_operand" "")))
+	(compare (match_operand:SI 0 "register_operand" "")
+		 (match_operand:SI 1 "const_int_le_6_operand" "")))
    (set (pc)
 	(if_then_else (match_operator 3 "eqne_operator"
 			[(cc0) (const_int 0)])
@@ -3527,8 +3527,8 @@
 
 (define_peephole2
   [(set (cc0)
-	(compare:SI (match_operand:SI 0 "register_operand" "")
-		    (match_operand:SI 1 "const_int_operand" "")))
+	(compare (match_operand:SI 0 "register_operand" "")
+		 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
 	(if_then_else (match_operator 3 "eqne_operator"
 			[(cc0) (const_int 0)])
@@ -3557,8 +3557,8 @@
 
 (define_peephole2
   [(set (cc0)
-	(compare:SI (match_operand:SI 0 "register_operand" "")
-		    (match_operand:SI 1 "const_int_operand" "")))
+	(compare (match_operand:SI 0 "register_operand" "")
+		 (match_operand:SI 1 "const_int_operand" "")))
    (set (pc)
 	(if_then_else (match_operator 2 "gtuleu_operator"
 			[(cc0) (const_int 0)])
@@ -3592,8 +3592,8 @@
 
 (define_peephole2
   [(set (cc0)
-	(compare:HI (match_operand:HI 0 "register_operand" "")
-		    (const_int 255)))
+	(compare (match_operand:HI 0 "register_operand" "")
+		 (const_int 255)))
    (set (pc)
 	(if_then_else (match_operator 1 "gtuleu_operator"
 			[(cc0) (const_int 0)])
@@ -3615,8 +3615,8 @@
 
 (define_peephole2
   [(set (cc0)
-	(compare:SI (match_operand:SI 0 "register_operand" "")
-		    (const_int 65535)))
+	(compare (match_operand:SI 0 "register_operand" "")
+		 (const_int 65535)))
    (set (pc)
 	(if_then_else (match_operator 1 "gtuleu_operator"
 			[(cc0) (const_int 0)])
@@ -3642,8 +3642,8 @@
 (define_peephole2
   [(match_scratch:SI 4 "r")
    (set (cc0)
-	(compare:SI (match_operand:SI 0 "register_operand" "")
-		    (match_operand:SI 1 "incdec_operand" "")))
+	(compare (match_operand:SI 0 "register_operand" "")
+		 (match_operand:SI 1 "incdec_operand" "")))
    (set (pc)
 	(if_then_else (match_operator 3 "eqne_operator"
 			[(cc0) (const_int 0)])


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