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] i386/x86_64 add[hsd]i_4* length bugfix


Hi!

On Thu, May 21, 2009 at 02:23:51PM +0200, Uros Bizjak wrote:
> I think that fixing the precision of insn lengths leads to better
> compiler decisions. The patch makes a lot of sense, and it is OK for
> mainline.

Thanks, committed.

Here is a small follow-up, when looking for the PLUS insns where both
128 and -128 can use shortened immediate because add*/sub* can be chosen
for smaller length, I've missed cases which are inverting that test (== -128
instead of == 128).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2009-05-21  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/i386.md (adddi_4_rex64, addsi_4, addhi_4): For
	operand2 -128 override length_immediate attribute to 1.
	* config/i386/predicates.md (constm128_operand): New predicate.

--- gcc/config/i386/i386.md.jj	2009-05-20 15:00:09.000000000 +0200
+++ gcc/config/i386/i386.md	2009-05-20 21:06:38.000000000 +0200
@@ -6648,6 +6648,11 @@
      (if_then_else (match_operand:DI 2 "incdec_operand" "")
 	(const_string "incdec")
 	(const_string "alu")))
+   (set (attr "length_immediate")
+      (if_then_else
+	(and (eq_attr "type" "alu") (match_operand 2 "constm128_operand" ""))
+	(const_string "1")
+	(const_string "*")))
    (set_attr "mode" "DI")])
 
 (define_insn "*adddi_5_rex64"
@@ -7114,6 +7119,11 @@
      (if_then_else (match_operand:SI 2 "incdec_operand" "")
 	(const_string "incdec")
 	(const_string "alu")))
+   (set (attr "length_immediate")
+      (if_then_else
+	(and (eq_attr "type" "alu") (match_operand 2 "constm128_operand" ""))
+	(const_string "1")
+	(const_string "*")))
    (set_attr "mode" "SI")])
 
 (define_insn "*addsi_5"
@@ -7397,6 +7407,11 @@
      (if_then_else (match_operand:HI 2 "incdec_operand" "")
 	(const_string "incdec")
 	(const_string "alu")))
+   (set (attr "length_immediate")
+      (if_then_else
+	(and (eq_attr "type" "alu") (match_operand 2 "constm128_operand" ""))
+	(const_string "1")
+	(const_string "*")))
    (set_attr "mode" "SI")])
 
 
--- gcc/config/i386/predicates.md.jj	2009-05-20 09:59:08.000000000 +0200
+++ gcc/config/i386/predicates.md	2009-05-20 21:03:30.000000000 +0200
@@ -587,6 +587,11 @@
   (and (match_code "const_int")
        (match_test "INTVAL (op) == 128")))
 
+;; Match exactly -128.
+(define_predicate "constm128_operand"
+  (and (match_code "const_int")
+       (match_test "INTVAL (op) == -128")))
+
 ;; Match 2, 4, or 8.  Used for leal multiplicands.
 (define_predicate "const248_operand"
   (match_code "const_int")


	Jakub


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