1 /* { dg-require-effective-target size32plus } */
2 /* { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" } */
3 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
4 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 /* { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target sse2_runtime } } } */
7 extern void abort (void);
8 int r
, a
[1024], b
[1024], x
, y
, z
;
10 __attribute__((noipa
)) void
13 #pragma omp for simd reduction (inscan, +:r) lastprivate (conditional: z) firstprivate (x) private (y) simdlen(1)
14 for (int i
= 0; i
< 1024; i
++)
16 { b
[i
] = r
; if ((i
& 1) == 0 && i
< 937) z
= r
; }
17 #pragma omp scan exclusive(r)
18 { y
= a
[i
]; r
+= y
+ x
+ 12; }
22 __attribute__((noipa
)) int
27 #pragma omp for simd reduction (inscan, +:s) firstprivate (x) private (y) lastprivate (z) if (0)
28 for (int i
= 0; i
< 1024; i
++)
30 { y
= s
; b
[i
] = y
+ x
+ 12; }
31 #pragma omp scan exclusive(s)
32 { y
= 2 * a
[i
]; s
+= y
; z
= y
; }
37 __attribute__((noipa
)) void
40 #pragma omp parallel for simd reduction (inscan, +:r) firstprivate (x) lastprivate (x)
41 for (int i
= 0; i
< 1024; i
++)
44 #pragma omp scan exclusive(r)
45 { r
+= a
[i
]; if (i
== 1023) x
= 29; }
49 __attribute__((noipa
)) int
53 #pragma omp parallel for simd reduction (inscan, +:s) lastprivate (conditional: x, y)
54 for (int i
= 0; i
< 1024; i
++)
56 { b
[i
] = s
; if ((a
[i
] & 1) == 0 && i
< 829) y
= a
[i
]; }
57 #pragma omp scan exclusive(s)
58 { s
+= 2 * a
[i
]; if ((a
[i
] & 1) == 1 && i
< 825) x
= a
[i
]; }
68 for (int i
= 0; i
< 1024; ++i
)
76 if (r
!= 1024 * 1023 / 2 || x
!= -12 || z
!= b
[936])
78 for (int i
= 0; i
< 1024; ++i
)
86 if (bar () != 1024 * 1023 || x
!= -12 || z
!= 2 * 1023)
89 for (int i
= 0; i
< 1024; ++i
)
99 if (r
!= 1024 * 1023 / 2 || x
!= 29)
102 for (int i
= 0; i
< 1024; ++i
)
110 if (qux () != 1024 * 1023 || x
!= 823 || y
!= 828)
113 for (int i
= 0; i
< 1024; ++i
)