Debian Codegraph @

gcc/testsuite/gcc.dg/vect/slp-43.c

raw
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-additional-options "-O3 -fno-version-loops-for-strides" } */
3
4 #include <string.h>
5 #include "tree-vect.h"
6
7 /* AVX512BW has V64QImode, make char_1 vectorizable with that. */
8 #define MAX_VEC_ELEMENTS 64
9
10 #define FOO(T,N) \
11 void __attribute__((noinline,noclone)) \
12 foo_ ## T ## _ ## N (T * __restrict__ in_, T * __restrict__ out_, int s) \
13 { \
14 T *in = __builtin_assume_aligned (in_, __BIGGEST_ALIGNMENT__); \
15 T *out = __builtin_assume_aligned (out_, __BIGGEST_ALIGNMENT__); \
16 for (int i = 0; i < MAX_VEC_ELEMENTS; i++) \
17 { \
18 for (int j = 0; j < N; ++j) \
19 out[j] = in[j]; \
20 in += s*N; \
21 out += N; \
22 } \
23 }
24
25 #define TEST(T,N) \
26 _Pragma("GCC novector") \
27 do { \
28 memset (out, 0, 4096); \
29 foo_ ## T ## _ ## N ((T *)in, (T *)out, 1); \
30 if (memcmp (in, out, sizeof (T) * MAX_VEC_ELEMENTS * N) != 0) \
31 __builtin_abort (); \
32 _Pragma("GCC novector") \
33 for (int i = sizeof (T) * MAX_VEC_ELEMENTS * N; i < 4096; ++i) \
34 if (out[i] != 0) \
35 __builtin_abort (); \
36 } while (0)
37
38 FOO(char, 1)
39 FOO(char, 2)
40 FOO(char, 3)
41 FOO(char, 4)
42 FOO(char, 6)
43 FOO(char, 8)
44 FOO(int, 1)
45 FOO(int, 2)
46 FOO(int, 3)
47 FOO(int, 4)
48 FOO(int, 6)
49 FOO(int, 8)
50 FOO(int, 16)
51
52 char in[4096] __attribute__((aligned(__BIGGEST_ALIGNMENT__)));
53 char out[4096] __attribute__((aligned(__BIGGEST_ALIGNMENT__)));
54
55 int main()
56 {
57 check_vect ();
58
59 for (int i = 0; i < 4096; ++i)
60 {
61 in[i] = i;
62 __asm__ volatile ("" : : : "memory");
63 }
64
65 TEST(char, 1);
66 TEST(char, 2);
67 TEST(char, 3);
68 TEST(char, 4);
69 TEST(char, 6);
70 TEST(char, 8);
71 TEST(int, 1);
72 TEST(int, 2);
73 TEST(int, 3);
74 TEST(int, 4);
75 TEST(int, 6);
76 TEST(int, 8);
77 TEST(int, 16);
78
79 return 0;
80 }
81
82 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 13 "vect" { target vect_hw_misalign } } } */
83 /* For ! vect_hw_misalign it depends on vector size and actual alignment
84 requirements of the target which functions can be vectorized. Avoid
85 that bean-counting and per-target listing here. */