sh.md (prefetch): Add condition for SH2A target.
authorNaveen.H.S <naveen.hs@kpitcummins.com>
Tue, 25 Mar 2008 13:38:45 +0000 (13:38 +0000)
committerKaz Kojima <kkojima@gcc.gnu.org>
Tue, 25 Mar 2008 13:38:45 +0000 (13:38 +0000)
* config/sh/sh.md (prefetch): Add condition for SH2A target.
(prefetch_sh2a): New.

* gcc.target/sh/sh2a-prefetch.c: New test.

From-SVN: r133516

gcc/ChangeLog
gcc/config/sh/sh.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/sh/sh2a-prefetch.c [new file with mode: 0644]

index 7ca50285e1f81343049fe1c2a92b65820559fab4..339c91e3dd92a78011de47f45421133cce58914b 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-25  Naveen.H.S  <naveen.hs@kpitcummins.com>
+
+       * config/sh/sh.md (prefetch): Add condition for SH2A target.
+       (prefetch_sh2a): New.   
+
 2008-03-25  Jayant Sonar  <Jayant.sonar@kpitcummins.com>
            Naveen.H.S  <naveen.hs@kpitcummins.com>
 
index 750e9d36d96df56fe86297622e7eb311542f94e7..0073370701edab8880724b87183ab1d47d17be8d 100644 (file)
@@ -13716,7 +13716,8 @@ mov.l\\t1f,r0\\n\\
   [(prefetch (match_operand 0 "address_operand" "p")
              (match_operand:SI 1 "const_int_operand" "n")
              (match_operand:SI 2 "const_int_operand" "n"))]
-  "(TARGET_HARD_SH4 || TARGET_SH5) && (TARGET_SHMEDIA || !TARGET_VXWORKS_RTP)"
+  "TARGET_SH2A || ((TARGET_HARD_SH4 || TARGET_SH5)
+   && (TARGET_SHMEDIA || !TARGET_VXWORKS_RTP))"
   "
 {
   if (GET_MODE (operands[0]) != Pmode
@@ -13727,6 +13728,14 @@ mov.l\\t1f,r0\\n\\
     operands[0] = force_reg (Pmode, operands[0]);
 }")
 
+(define_insn "prefetch_m2a"
+  [(prefetch (match_operand:SI 0 "register_operand" "r")
+            (match_operand:SI 1 "const_int_operand" "n")
+            (match_operand:SI 2 "const_int_operand" "n"))]
+  "TARGET_SH2A"
+  "pref\\t@%0"
+  [(set_attr "type" "other")])
+
 (define_insn "alloco_i"
   [(set (mem:BLK (match_operand:QI 0 "cache_address_operand" "p"))
        (unspec:BLK [(const_int 0)] UNSPEC_ALLOCO))]
index 7cee9300aed4545af914a5b9cf8d11e33b3e554b..f61cfcf55077b540bb7731242e4584dd75f5cc33 100644 (file)
@@ -1,3 +1,7 @@
+2008-03-25  Naveen.H.S  <naveen.hs@kpitcummins.com>
+
+       * gcc.target/sh/sh2a-prefetch.c: New test.
+
 2008-03-25  Jayant Sonar  <Jayant.sonar@kpitcummins.com>
            Naveen.H.S  <naveen.hs@kpitcummins.com>
 
diff --git a/gcc/testsuite/gcc.target/sh/sh2a-prefetch.c b/gcc/testsuite/gcc.target/sh/sh2a-prefetch.c
new file mode 100644 (file)
index 0000000..e0c9a0d
--- /dev/null
@@ -0,0 +1,34 @@
+/* Testcase to check generation of a SH2A specific instruction PREF @Rm.  */
+/* { dg-do assemble {target sh*-*-*}}  */
+/* { dg-options "-O0" }  */
+/* { dg-skip-if "" { "sh*-*-*" } "*" "-m2a -m2a-nofpu -m2a-single -m2a-single-only" }  */
+/* { dg-final { scan-assembler "pref"} }  */
+
+void
+opt (void)
+{
+  int *p, wk;
+  int data[100];
+
+  /* data prefetch , instructions hit the cache. */
+
+  __builtin_prefetch (&data[0], 0, 0);
+  __builtin_prefetch (&data[0], 0, 1);
+  __builtin_prefetch (&data[0], 0, 2);
+  __builtin_prefetch (&data[0], 0, 3);
+  __builtin_prefetch (&data[0], 1, 0);
+  __builtin_prefetch (&data[0], 1, 1);
+  __builtin_prefetch (&data[0], 1, 2);
+  __builtin_prefetch (&data[0], 1, 3);
+
+
+  for (p = &data[0]; p < &data[9]; p++)
+    {
+      if (*p > *(p + 1))
+        {
+          wk = *p;
+          *p = *(p + 1);
+          *(p + 1) = wk;
+        }
+    }
+}