1 /* { dg-require-effective-target size32plus } */
2 /* { dg-additional-options "-fopenmp-simd" } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
4 /* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } */
10 int r
, a
[1024], b
[1024];
11 unsigned short r2
, b2
[1024];
12 unsigned char r3
, b3
[1024];
14 __attribute__((noipa
)) void
15 foo (int *a
, int *b
, unsigned short *b2
, unsigned char *b3
)
17 #pragma omp simd reduction (inscan, +:r, r2, r3)
18 for (int i
= 0; i
< 1024; i
++)
25 #pragma omp scan exclusive(r, r2, r3)
26 { r
+= a
[i
]; r2
+= a
[i
]; r3
+= a
[i
]; }
30 __attribute__((noipa
)) int
31 bar (unsigned short *s2p
, unsigned char *s3p
)
34 unsigned short s2
= 0;
36 #pragma omp simd reduction (inscan, +:s, s2, s3)
37 for (int i
= 0; i
< 1024; i
++)
39 { b
[i
] = s
; b2
[i
] = s2
; b3
[i
] = s3
; }
40 #pragma omp scan exclusive(s, s2, s3)
52 __attribute__((noipa
)) void
53 baz (int *a
, int *b
, unsigned short *b2
, unsigned char *b3
)
55 #pragma omp simd reduction (inscan, +:r, r2, r3) if (simd: 0)
56 for (int i
= 0; i
< 1024; i
++)
63 #pragma omp scan exclusive(r, r2, r3)
72 __attribute__((noipa
)) int
73 qux (unsigned short *s2p
, unsigned char *s3p
)
76 unsigned short s2
= 0;
78 #pragma omp simd reduction (inscan, +:s, s2, s3) simdlen (1)
79 for (int i
= 0; i
< 1024; i
++)
81 { b
[i
] = s
; b2
[i
] = s2
; b3
[i
] = s3
; }
82 #pragma omp scan exclusive(s, s2, s3)
83 { s
+= 2 * a
[i
]; s2
+= 2 * a
[i
]; s3
+= 2 * a
[i
]; }
99 for (int i
= 0; i
< 1024; ++i
)
108 if (r
!= 1024 * 1023 / 2
109 || r2
!= (unsigned short) r
110 || r3
!= (unsigned char) r
)
113 for (int i
= 0; i
< 1024; ++i
)
116 || b2
[i
] != (unsigned short) s
117 || b3
[i
] != (unsigned char) s
)
127 if (bar (&s2
, &s3
) != 1024 * 1023)
129 if (s2
!= (unsigned short) (1024 * 1023)
130 || s3
!= (unsigned char) (1024 * 1023))
134 for (int i
= 0; i
< 1024; ++i
)
137 || b2
[i
] != (unsigned short) s
138 || b3
[i
] != (unsigned char) s
)
152 if (r
!= 1024 * 1023 / 2
153 || r2
!= (unsigned short) r
154 || r3
!= (unsigned char) r
)
158 for (int i
= 0; i
< 1024; ++i
)
161 || b2
[i
] != (unsigned short) s
162 || b3
[i
] != (unsigned char) s
)
174 if (qux (&s2
, &s3
) != 1024 * 1023)
176 if (s2
!= (unsigned short) (1024 * 1023)
177 || s3
!= (unsigned char) (1024 * 1023))
181 for (int i
= 0; i
< 1024; ++i
)
184 || b2
[i
] != (unsigned short) s
185 || b3
[i
] != (unsigned char) s
)