summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/sh/sh2a-prefetch.c
blob: e0c9a0d7dc65a24d288f3c1fd226b899c4dcc61c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
        }
    }
}