aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.hsa.c/switch-sbr-2.c
blob: 06990d1c2c065b61e572cd3bb9b6988fd05d9bab (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* { dg-additional-options "-fno-tree-switch-conversion" } */

#pragma omp declare target
int
foo (unsigned a)
{
  switch (a)
    {
    case 1 ... 5:
      return 1;
    case 9 ... 11:
      return a + 3;
    case 12 ... 13:
      return a + 3;
    default:
      return 44;
    }
}
#pragma omp end declare target

#define s 100

void __attribute__((noinline, noclone))
verify(int *a)
{
  if (a[0] != 44)
    __builtin_abort ();
  
  for (int i = 1; i <= 5; i++)
    if (a[i] != 1)
      __builtin_abort ();

  for (int i = 6; i <= 8; i++)
    if (a[i] != 44)
      __builtin_abort ();

  for (int i = 9; i <= 13; i++)
    if (a[i] != i + 3)
      __builtin_abort ();

  for (int i = 14; i < s; i++)
    if (a[i] != 44)
      __builtin_abort ();
}

int main(int argc)
{
  int array[s];
#pragma omp target
  {
    for (int i = 0; i < s; i++)
      {
	int v = foo (i);
	array[i] = v;
      }
  }
  verify (array);
  return 0;
}