Do not cost the permute node that are part of SLP load-lanes
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / target-in-reduction-1.c
blob813b5d95d3dd1752cfa44af7d07a0cbd7818bfed
1 void
2 foo (int x, int *y, int n, int v)
4 int z[3] = { 45, 46, 47 };
5 int u[n], w[n], i;
6 for (i = 0; i < n; i++)
7 w[i] = u[i] = n + i;
8 #pragma omp taskgroup task_reduction (+: x, y[:2], z[1:2], u, w[1:v])
10 #pragma omp task in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
12 x++;
13 y[0] += 2;
14 y[1] += 3;
15 z[1] += 4;
16 u[0] += 5;
17 w[1] += 6;
19 #pragma omp target in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
21 x += 4;
22 y[0] += 5;
23 y[1] += 6;
24 z[2] += 7;
25 u[1] += 8;
26 w[2] += 7;
28 #pragma omp target in_reduction (+: x, y[:v], z[1:v], u, w[1:2])
30 x += 9;
31 y[0] += 10;
32 y[1] += 11;
33 z[1] += 12;
34 u[2] += 13;
35 w[1] += 14;
38 if (x != 56 || y[0] != 60 || y[1] != 64)
39 __builtin_abort ();
40 if (z[0] != 45 || z[1] != 62 || z[2] != 54)
41 __builtin_abort ();
42 if (u[0] != 8 || u[1] != 12 || u[2] != 18)
43 __builtin_abort ();
44 if (w[0] != 3 || w[1] != 24 || w[2] != 12)
45 __builtin_abort ();
48 void
49 bar (int x, int *y, int n, int v)
51 int z[3] = { 45, 46, 47 };
52 int u[n], w[n], i;
53 for (i = 0; i < n; i++)
54 w[i] = u[i] = n + i;
55 #pragma omp parallel master
56 #pragma omp taskgroup task_reduction (+: x, y[:2], z[1:2], u, w[1:v])
58 #pragma omp task in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
60 x++;
61 y[0] += 2;
62 y[1] += 3;
63 z[1] += 4;
64 u[0] += 5;
65 w[1] += 6;
67 #pragma omp target in_reduction (+: x, y[:2], z[1:2], u, w[1:v])
69 x += 4;
70 y[0] += 5;
71 y[1] += 6;
72 z[2] += 7;
73 u[1] += 8;
74 w[2] += 7;
76 #pragma omp target in_reduction (+: x, y[:v], z[1:v], u, w[1:2])
78 x += 9;
79 y[0] += 10;
80 y[1] += 11;
81 z[1] += 12;
82 u[2] += 13;
83 w[1] += 14;
86 if (x != 56 || y[0] != 77 || y[1] != 84)
87 __builtin_abort ();
88 if (z[0] != 45 || z[1] != 62 || z[2] != 54)
89 __builtin_abort ();
90 if (u[0] != 8 || u[1] != 12 || u[2] != 18)
91 __builtin_abort ();
92 if (w[0] != 3 || w[1] != 24 || w[2] != 12)
93 __builtin_abort ();
96 int
97 main ()
99 int y[2] = { 43, 44 };
100 #pragma omp parallel master
101 foo (42, y, 3, 2);
102 bar (42, y, 3, 2);
103 return 0;