111
|
1 /* { dg-require-weak "" } */
|
131
|
2 /* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } } */
|
|
3 /* { dg-skip-if "No undefined weak" { nvptx-*-* } } */
|
|
4 /* { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */
|
|
5 /* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */
|
111
|
6 /* { dg-additional-options "--param vect-epilogues-nomask=1 -mavx2" { target avx2_runtime } } */
|
|
7
|
|
8 #define SIZE 1023
|
|
9 #define ALIGN 64
|
|
10
|
|
11 extern int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size) __attribute__((weak));
|
|
12 extern void free (void *);
|
|
13
|
|
14 void __attribute__((noinline))
|
|
15 test_citer (int * __restrict__ a,
|
|
16 int * __restrict__ b,
|
|
17 int * __restrict__ c)
|
|
18 {
|
|
19 int i;
|
|
20
|
|
21 a = (int *)__builtin_assume_aligned (a, ALIGN);
|
|
22 b = (int *)__builtin_assume_aligned (b, ALIGN);
|
|
23 c = (int *)__builtin_assume_aligned (c, ALIGN);
|
|
24
|
|
25 for (i = 0; i < SIZE; i++)
|
|
26 c[i] = a[i] + b[i];
|
|
27 }
|
|
28
|
|
29 void __attribute__((noinline))
|
|
30 test_viter (int * __restrict__ a,
|
|
31 int * __restrict__ b,
|
|
32 int * __restrict__ c,
|
|
33 int size)
|
|
34 {
|
|
35 int i;
|
|
36
|
|
37 a = (int *)__builtin_assume_aligned (a, ALIGN);
|
|
38 b = (int *)__builtin_assume_aligned (b, ALIGN);
|
|
39 c = (int *)__builtin_assume_aligned (c, ALIGN);
|
|
40
|
|
41 for (i = 0; i < size; i++)
|
|
42 c[i] = a[i] + b[i];
|
|
43 }
|
|
44
|
|
45 void __attribute__((noinline))
|
|
46 init_data (int * __restrict__ a,
|
|
47 int * __restrict__ b,
|
|
48 int * __restrict__ c,
|
|
49 int size)
|
|
50 {
|
|
51 for (int i = 0; i < size; i++)
|
|
52 {
|
|
53 a[i] = i;
|
|
54 b[i] = -i;
|
|
55 c[i] = 0;
|
|
56 asm volatile("": : :"memory");
|
|
57 }
|
|
58 a[size] = b[size] = c[size] = size;
|
|
59 }
|
|
60
|
|
61
|
|
62 void __attribute__((noinline))
|
|
63 run_test ()
|
|
64 {
|
|
65 int *a;
|
|
66 int *b;
|
|
67 int *c;
|
|
68 int i;
|
|
69
|
|
70 if (posix_memalign ((void **)&a, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
|
|
71 return;
|
|
72 if (posix_memalign ((void **)&b, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
|
|
73 return;
|
|
74 if (posix_memalign ((void **)&c, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
|
|
75 return;
|
|
76
|
|
77 init_data (a, b, c, SIZE);
|
|
78 test_citer (a, b, c);
|
|
79 for (i = 0; i < SIZE; i++)
|
|
80 if (c[i] != a[i] + b[i])
|
|
81 __builtin_abort ();
|
|
82 if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE)
|
|
83 __builtin_abort ();
|
|
84
|
|
85 init_data (a, b, c, SIZE);
|
|
86 test_viter (a, b, c, SIZE);
|
|
87 for (i = 0; i < SIZE; i++)
|
|
88 if (c[i] != a[i] + b[i])
|
|
89 __builtin_abort ();
|
|
90 if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE)
|
|
91 __builtin_abort ();
|
|
92
|
|
93 free (a);
|
|
94 free (b);
|
|
95 free (c);
|
|
96 }
|
|
97
|
|
98 int
|
|
99 main (int argc, const char **argv)
|
|
100 {
|
|
101 if (!posix_memalign)
|
|
102 return 0;
|
|
103
|
|
104 run_test ();
|
|
105 return 0;
|
|
106 }
|
|
107
|
|
108 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target avx2_runtime } } } */
|
|
109 /* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(VS=16\\)" 2 "vect" { target avx2_runtime } } } */
|