1 /* { dg-require-effective-target vect_bswap } */
2 
3 #include "tree-vect.h"
4 
5 #define N 128
6 
7 static inline void
vfoo16(unsigned short int * a)8 vfoo16 (unsigned short int* a)
9 {
10   int i = 0;
11   for (i = 0; i < N; ++i)
12     a[i] = __builtin_bswap16 (a[i]);
13 }
14 
15 int
main(void)16 main (void)
17 {
18   unsigned short arr[N];
19   unsigned short expect[N];
20   int i;
21 
22   check_vect ();
23 
24   for (i = 0; i < N; ++i)
25     {
26       arr[i] = i;
27       expect[i] = __builtin_bswap16 (i);
28       asm volatile ("" ::: "memory");
29     }
30 
31   vfoo16 (arr);
32 
33   for (i = 0; i < N; ++i)
34     {
35       if (arr[i] != expect[i])
36         abort ();
37     }
38 
39   return 0;
40 }
41 
42 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
43