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.

The new pattern optimizes

  unsigned short A;
  ((unsigned long) A) << 15;

into

  (A << 16) >> 1

This occurs in newlib.

Tested on h8300 port.  Committed.

Kazu Hirata

2003-01-06  Kazu Hirata  <kazu@cs.umass.edu>

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

Index: h8300.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.md,v
retrieving revision 1.145
diff -u -r1.145 h8300.md
--- h8300.md	5 Jan 2003 23:04:48 -0000	1.145
+++ h8300.md	6 Jan 2003 14:00:33 -0000
@@ -2576,6 +2576,28 @@
 	      (clobber (scratch:QI))])]
   "")
 
+;; and:SI
+
+;; ((SImode) HImode) << 15
+
+(define_insn_and_split "*twoshifts_l16_r1"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+	(and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
+			   (const_int 15))
+		(const_int 2147450880)))]
+  "(TARGET_H8300H || TARGET_H8300S)"
+  "#"
+  "&& reload_completed"
+  [(parallel [(set (match_dup 0)
+		   (ashift:SI (match_dup 0)
+			      (const_int 16)))
+	      (clobber (scratch:QI))])
+   (parallel [(set (match_dup 0)
+		   (lshiftrt:SI (match_dup 0)
+				(const_int 1)))
+	      (clobber (scratch:QI))])]
+  "")
+
 ;; plus:SI
 
 (define_insn "*addsi3_lshiftrt_16_zexthi"


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