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]

Improve i386 add


Hi,
in some cases we end up reloading allocating registers so add match in reverse
(ie argument 2 is equivalent to the destination).  Apparently no one is required
to canonicalize this and then i386 splitters gets confused threading this as lea.

Tue Mar 25 23:35:37 CET 2003  Jan Hubicka  <jh at suse dot cz>
	* i386.md: New splitters to canonicalize order of arguments for AND.
Index: i386.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.md,v
retrieving revision 1.380.2.26
diff -c -3 -p -r1.380.2.26 i386.md
*** i386.md	25 Mar 2003 16:39:14 -0000	1.380.2.26
--- i386.md	25 Mar 2003 22:35:15 -0000
***************
*** 5538,5543 ****
--- 5538,5557 ----
  	   (const_string "alu")))
     (set_attr "mode" "DI")])
  
+ ;; We may end up with add pattern and operand swapped.  Avoid it
+ ;; being turned into lea.
+ (define_split
+   [(set (match_operand:DI 0 "register_operand" "")
+ 	(plus:DI (match_operand:DI 1 "nonimmediate_operand" "")
+ 		 (match_dup 0)))
+    (clobber (reg:CC 17))]
+   ""
+   [(parallel [(set (match_dup 0)
+ 		   (plus:DI (match_dup 0)
+ 			    (match_dup 1)))
+ 	      (clobber (reg:CC 17))])]
+   "")
+ 
  ;; Convert lea to the lea pattern to avoid flags dependency.
  (define_split
    [(set (match_operand:DI 0 "register_operand" "")
***************
*** 5804,5809 ****
--- 5818,5837 ----
  	   (const_string "alu")))
     (set_attr "mode" "SI")])
  
+ ;; We may end up with add pattern and operand swapped.  Avoid it
+ ;; being turned into lea.
+ (define_split
+   [(set (match_operand:SI 0 "register_operand" "")
+ 	(plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
+ 		 (match_dup 0)))
+    (clobber (reg:CC 17))]
+   ""
+   [(parallel [(set (match_dup 0)
+ 		   (plus:SI (match_dup 0)
+ 			    (match_dup 1)))
+ 	      (clobber (reg:CC 17))])]
+   "")
+ 
  ;; Convert lea to the lea pattern to avoid flags dependency.
  (define_split
    [(set (match_operand 0 "register_operand" "")
***************
*** 5884,5889 ****
--- 5912,5931 ----
  	   (const_string "alu")))
     (set_attr "mode" "SI")])
  
+ ;; We may end up with add pattern and operand swapped.  Avoid it
+ ;; being turned into lea.
+ (define_split
+   [(set (match_operand:SI 0 "register_operand" "")
+ 	(plus:SI (match_operand:SI 1 "nonimmediate_operand" "")
+ 		 (match_dup 0)))
+    (clobber (reg:CC 17))]
+   ""
+   [(parallel [(set (match_dup 0)
+ 		   (plus:SI (match_dup 0)
+ 			    (match_dup 1)))
+ 	      (clobber (reg:CC 17))])]
+   "")
+ 
  ;; Convert lea to the lea pattern to avoid flags dependency.
  (define_split
    [(set (match_operand:DI 0 "register_operand" "")
***************
*** 6226,6231 ****
--- 6268,6287 ----
  	   (const_string "alu"))))
     (set_attr "mode" "HI,HI,SI")])
  
+ ;; We may end up with add pattern and operand swapped.  Avoid it
+ ;; being turned into lea.
+ (define_split
+   [(set (match_operand:HI 0 "register_operand" "")
+ 	(plus:HI (match_operand:HI 1 "nonimmediate_operand" "")
+ 		 (match_dup 0)))
+    (clobber (reg:CC 17))]
+   ""
+   [(parallel [(set (match_dup 0)
+ 		   (plus:HI (match_dup 0)
+ 			    (match_dup 1)))
+ 	      (clobber (reg:CC 17))])]
+   "")
+ 
  (define_insn "*addhi_1"
    [(set (match_operand:HI 0 "nonimmediate_operand" "=rm,r")
  	(plus:HI (match_operand:HI 1 "nonimmediate_operand" "%0,0")
***************
*** 6475,6480 ****
--- 6531,6550 ----
  	   (const_string "alu"))))
     (set_attr "mode" "QI,QI,SI,SI")])
  
+ ;; We may end up with add pattern and operand swapped.  Avoid it
+ ;; being turned into lea.
+ (define_split
+   [(set (match_operand:QI 0 "register_operand" "")
+ 	(plus:QI (match_operand:QI 1 "nonimmediate_operand" "")
+ 		 (match_dup 0)))
+    (clobber (reg:CC 17))]
+   ""
+   [(parallel [(set (match_dup 0)
+ 		   (plus:QI (match_dup 0)
+ 			    (match_dup 1)))
+ 	      (clobber (reg:CC 17))])]
+   "")
+ 
  (define_insn "*addqi_1"
    [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r")
  	(plus:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")


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