Patchwork [i386] : Macroize prefetch patterns

login
register
mail settings
Submitter Uros Bizjak
Date June 15, 2010, 9:16 p.m.
Message ID <1276636608.3406.2.camel@localhost>
Download mbox | patch
Permalink /patch/55799/
State New
Headers show

Comments

Uros Bizjak - June 15, 2010, 9:16 p.m.
Hello!

2010-06-15  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (*prefetch_sse_<mode>):  Macroize insn from
	*prefetch_sse and *prefetch_sse_rex using P mode iterator.
	(*prefetch_3dnow_<mode>): Ditto from *prefetch_3dnow and
	*prefetch_3dnow_rex.

Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline.

Uros.

Patch

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 160811)
+++ config/i386/i386.md	(working copy)
@@ -18194,11 +18194,11 @@ 
     operands[1] = const0_rtx;
 })
 
-(define_insn "*prefetch_sse"
-  [(prefetch (match_operand:SI 0 "address_operand" "p")
+(define_insn "*prefetch_sse_<mode>"
+  [(prefetch (match_operand:P 0 "address_operand" "p")
 	     (const_int 0)
 	     (match_operand:SI 1 "const_int_operand" ""))]
-  "TARGET_PREFETCH_SSE && !TARGET_64BIT"
+  "TARGET_PREFETCH_SSE"
 {
   static const char * const patterns[4] = {
    "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
@@ -18211,34 +18211,15 @@ 
 }
   [(set_attr "type" "sse")
    (set_attr "atom_sse_attr" "prefetch")
-   (set (attr "length_address") (symbol_ref "memory_address_length (operands[0])"))
+   (set (attr "length_address")
+	(symbol_ref "memory_address_length (operands[0])"))
    (set_attr "memory" "none")])
 
-(define_insn "*prefetch_sse_rex"
-  [(prefetch (match_operand:DI 0 "address_operand" "p")
-	     (const_int 0)
-	     (match_operand:SI 1 "const_int_operand" ""))]
-  "TARGET_PREFETCH_SSE && TARGET_64BIT"
-{
-  static const char * const patterns[4] = {
-   "prefetchnta\t%a0", "prefetcht2\t%a0", "prefetcht1\t%a0", "prefetcht0\t%a0"
-  };
-
-  int locality = INTVAL (operands[1]);
-  gcc_assert (locality >= 0 && locality <= 3);
-
-  return patterns[locality];
-}
-  [(set_attr "type" "sse")
-   (set_attr "atom_sse_attr" "prefetch")
-   (set (attr "length_address") (symbol_ref "memory_address_length (operands[0])"))
-   (set_attr "memory" "none")])
-
-(define_insn "*prefetch_3dnow"
-  [(prefetch (match_operand:SI 0 "address_operand" "p")
+(define_insn "*prefetch_3dnow_<mode>"
+  [(prefetch (match_operand:P 0 "address_operand" "p")
 	     (match_operand:SI 1 "const_int_operand" "n")
 	     (const_int 3))]
-  "TARGET_3DNOW && !TARGET_64BIT"
+  "TARGET_3DNOW"
 {
   if (INTVAL (operands[1]) == 0)
     return "prefetch\t%a0";
@@ -18246,24 +18227,10 @@ 
     return "prefetchw\t%a0";
 }
   [(set_attr "type" "mmx")
-   (set (attr "length_address") (symbol_ref "memory_address_length (operands[0])"))
+   (set (attr "length_address")
+	(symbol_ref "memory_address_length (operands[0])"))
    (set_attr "memory" "none")])
 
-(define_insn "*prefetch_3dnow_rex"
-  [(prefetch (match_operand:DI 0 "address_operand" "p")
-	     (match_operand:SI 1 "const_int_operand" "n")
-	     (const_int 3))]
-  "TARGET_3DNOW && TARGET_64BIT"
-{
-  if (INTVAL (operands[1]) == 0)
-    return "prefetch\t%a0";
-  else
-    return "prefetchw\t%a0";
-}
-  [(set_attr "type" "mmx")
-   (set (attr "length_address") (symbol_ref "memory_address_length (operands[0])"))
-   (set_attr "memory" "none")])
-
 (define_expand "stack_protect_set"
   [(match_operand 0 "memory_operand" "")
    (match_operand 1 "memory_operand" "")]