PR target/82855
[official-gcc.git] / libgomp / testsuite / libgomp.c / simd-15.c
blobe75538d06e535ea07d3834dba5709b904199cde5
1 /* { dg-do run } */
2 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 static inline void
6 foo (int *b, int *i, int *j, int x)
8 *b = *b + x + (*i - *i) + (*j - *j);
11 int
12 main ()
14 int i, j, b, c = 0;
15 i = 4; j = 4; b = 7;
16 #pragma omp simd linear(b:2) reduction(+:c)
17 for (i = 0; i < 64; i++)
19 c = c + (b != 7 + 2 * i);
20 foo (&b, &i, &j, 2);
22 if (c || i != 64 || b != 7 + 64 * 2)
23 __builtin_abort ();
24 i = 4; j = 4; b = 7;
25 #pragma omp simd linear(b:3) reduction(+:c)
26 for (i = 0; i < 64; i += 4)
28 c = c + (b != 7 + i / 4 * 3);
29 foo (&b, &i, &j, 3);
31 if (c || i != 64 || b != 7 + 16 * 3)
32 __builtin_abort ();
33 i = 4; j = 4; b = 7;
34 #pragma omp simd linear(i) linear(b:2) reduction(+:c)
35 for (i = 0; i < 64; i++)
37 c = c + (b != 7 + 2 * i);
38 foo (&b, &i, &j, 2);
40 if (c || i != 64 || b != 7 + 64 * 2)
41 __builtin_abort ();
42 i = 4; j = 4; b = 7;
43 #pragma omp simd linear(i:4) linear(b:3) reduction(+:c)
44 for (i = 0; i < 64; i += 4)
46 c = c + (b != 7 + i / 4 * 3);
47 foo (&b, &i, &j, 3);
49 if (c || i != 64 || b != 7 + 16 * 3)
50 __builtin_abort ();
51 i = 4; j = 4; b = 7;
52 #pragma omp simd collapse (2) linear(b:2) reduction(+:c)
53 for (i = 0; i < 8; i++)
54 for (j = 0; j < 8; j++)
56 c = c + (b != 7 + 2 * j + 2 * 8 * i);
57 foo (&b, &i, &j, 2);
59 if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
60 __builtin_abort ();
61 i = 4; j = 4; b = 7;
62 #pragma omp simd collapse (2) lastprivate (i, j) linear(b:2) reduction(+:c)
63 for (i = 0; i < 8; i++)
64 for (j = 0; j < 8; j++)
66 c = c + (b != 7 + 2 * j + 2 * 8 * i);
67 foo (&b, &i, &j, 2);
69 if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
70 __builtin_abort ();
71 i = 4; j = 4; b = 7;
72 #pragma omp parallel for simd schedule (static, 4) linear(b:2) reduction(+:c)
73 for (i = 0; i < 64; i++)
75 c = c + (b != 7 + 2 * i);
76 foo (&b, &i, &j, 2);
78 if (c || i != 64 || b != 7 + 64 * 2)
79 __builtin_abort ();
80 i = 4; j = 4; b = 7;
81 #pragma omp parallel for simd schedule (static, 4) linear(b:3) reduction(+:c)
82 for (i = 0; i < 64; i += 4)
84 c = c + (b != 7 + i / 4 * 3);
85 foo (&b, &i, &j, 3);
87 if (c || i != 64 || b != 7 + 16 * 3)
88 __builtin_abort ();
89 i = 4; j = 4; b = 7;
90 #pragma omp parallel for simd schedule (static, 4) linear(i) linear(b:2) reduction(+:c)
91 for (i = 0; i < 64; i++)
93 c = c + (b != 7 + 2 * i);
94 foo (&b, &i, &j, 2);
96 if (c || i != 64 || b != 7 + 64 * 2)
97 __builtin_abort ();
98 i = 4; j = 4; b = 7;
99 #pragma omp parallel for simd schedule (static, 4) linear(i:4) linear(b:3) reduction(+:c)
100 for (i = 0; i < 64; i += 4)
102 c = c + (b != 7 + i / 4 * 3);
103 foo (&b, &i, &j, 3);
105 if (c || i != 64 || b != 7 + 16 * 3)
106 __builtin_abort ();
107 i = 4; j = 4; b = 7;
108 #pragma omp parallel for simd lastprivate (i, j) collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
109 for (i = 0; i < 8; i++)
110 for (j = 0; j < 8; j++)
112 c = c + (b != 7 + 2 * j + 2 * 8 * i);
113 foo (&b, &i, &j, 2);
115 if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
116 __builtin_abort ();
117 i = 4; j = 4; b = 7;
118 #pragma omp parallel for simd collapse (2) schedule (static, 4) linear(b:2) reduction(+:c)
119 for (i = 0; i < 8; i++)
120 for (j = 0; j < 8; j++)
122 c = c + (b != 7 + 2 * j + 2 * 8 * i);
123 foo (&b, &i, &j, 2);
125 if (c || i != 8 || j != 8 || b != 7 + 64 * 2)
126 __builtin_abort ();
127 return 0;