2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / vect / pr87914.cc
blob12fbba3af2fc81f0d82bc1f636b0b65fb29883aa
1 // { dg-do run }
2 // { dg-additional-options "-fopenmp-simd" }
3 // { dg-additional-options "-mavx2" { target { avx2_runtime } } }
5 extern "C" int memcmp(const void *s1, const void *s2, __SIZE_TYPE__ n);
6 extern "C" void abort(void);
8 template <typename T>
9 T reverseBits(T x)
11 unsigned int s = sizeof(x) * 8;
12 T mask = ~T(0);
13 while ((s >>= 1) > 0)
15 mask ^= (mask << s);
16 x = ((x >> s) & mask) | ((x << s) & ~mask); // unsupported use in stmt
18 return x;
21 void __attribute__((noinline,noipa))
22 test_reverseBits(unsigned* x)
24 #pragma omp simd aligned(x:32)
25 for (int i = 0; i < 16; ++i)
26 x[i] = reverseBits(x[i]); // couldn't vectorize loop
29 int main()
31 unsigned arr[16] __attribute__((aligned(32)))
32 = { 0x01020304, 0x05060708, 0x0a0b0c0d, 0x0e0f1011,
33 0x11121314, 0x45065708, 0xfa0b3c0du, 0x0e0f1211,
34 0x21222324, 0x55066708, 0xfa0b2c0du, 0x1e0f1011,
35 0x31323334, 0x65067708, 0xfa0b5c0du, 0x0e3f1011 };
36 unsigned arr2[16]
37 = { 0x20c04080, 0x10e060a0, 0xb030d050, 0x8808f070u,
38 0x28c84888, 0x10ea60a2, 0xb03cd05f, 0x8848f070u,
39 0x24c44484, 0x10e660aa, 0xb034d05f, 0x8808f078u,
40 0x2ccc4c8c, 0x10ee60a6, 0xb03ad05f, 0x8808fc70u };
42 test_reverseBits (arr);
44 if (memcmp (arr, arr2, sizeof (arr)) != 0)
45 abort ();
46 return 0;
49 // { dg-final { scan-tree-dump "OUTER LOOP VECTORIZED" "vect" { target { vect_var_shift && vect_int } } } }