Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-simd-6.c

raw
1 /* { dg-additional-options "-fopenmp-simd" } */
2 /* { dg-final { scan-tree-dump-times "vectorized \[12] loops" 2 "vect" { target vect_condition } } } */
3
4 #include "tree-vect.h"
5
6 int v;
7
8 __attribute__((noipa)) int
9 foo (int *a)
10 {
11 int x = 5;
12 #pragma omp simd lastprivate (conditional: x)
13 for (int i = 0; i < 128; i++)
14 if (a[i])
15 x = a[i];
16 return x;
17 }
18
19 __attribute__((noipa)) int
20 bar (int *a, int *b)
21 {
22 int x = 0;
23 #pragma omp simd lastprivate (conditional: x, v)
24 for (int i = 16; i < 128; ++i)
25 {
26 if (a[i])
27 x = a[i];
28 if (b[i])
29 v = b[i] + 10;
30 }
31 return x;
32 }
33
34 int
35 main ()
36 {
37 int a[128], b[128], i;
38 check_vect ();
39 for (i = 0; i < 128; i++)
40 {
41 a[i] = ((i % 11) == 2) ? i + 10 : 0;
42 asm volatile ("" : "+g" (i));
43 b[i] = ((i % 13) == 5) ? i * 2 : 0;
44 }
45 if (foo (a) != 133)
46 abort ();
47 if (bar (b, a) != 244)
48 abort ();
49 if (v != 143)
50 abort ();
51 return 0;
52 }