1 /* { dg-skip-if "No undefined weak" { ! { posix_memalign } } } */
2 /* { dg-additional-options "--param vect-epilogues-nomask=1 -mavx2" { target avx2_runtime } } */
7 extern int posix_memalign(void **memptr
, __SIZE_TYPE__ alignment
, __SIZE_TYPE__ size
);
8 extern void free (void *);
10 void __attribute__((noinline
))
11 test_citer (int * __restrict__ a
,
17 a
= (int *)__builtin_assume_aligned (a
, ALIGN
);
18 b
= (int *)__builtin_assume_aligned (b
, ALIGN
);
19 c
= (int *)__builtin_assume_aligned (c
, ALIGN
);
21 for (i
= 0; i
< SIZE
; i
++)
25 void __attribute__((noinline
))
26 test_viter (int * __restrict__ a
,
33 a
= (int *)__builtin_assume_aligned (a
, ALIGN
);
34 b
= (int *)__builtin_assume_aligned (b
, ALIGN
);
35 c
= (int *)__builtin_assume_aligned (c
, ALIGN
);
37 for (i
= 0; i
< size
; i
++)
41 void __attribute__((noinline
))
42 init_data (int * __restrict__ a
,
47 for (int i
= 0; i
< size
; i
++)
52 asm volatile("": : :"memory");
54 a
[size
] = b
[size
] = c
[size
] = size
;
58 void __attribute__((noinline
))
66 if (posix_memalign ((void **)&a
, ALIGN
, (SIZE
+ 1) * sizeof (int)) != 0)
68 if (posix_memalign ((void **)&b
, ALIGN
, (SIZE
+ 1) * sizeof (int)) != 0)
70 if (posix_memalign ((void **)&c
, ALIGN
, (SIZE
+ 1) * sizeof (int)) != 0)
73 init_data (a
, b
, c
, SIZE
);
76 for (i
= 0; i
< SIZE
; i
++)
77 if (c
[i
] != a
[i
] + b
[i
])
79 if (a
[SIZE
] != SIZE
|| b
[SIZE
] != SIZE
|| c
[SIZE
] != SIZE
)
82 init_data (a
, b
, c
, SIZE
);
83 test_viter (a
, b
, c
, SIZE
);
85 for (i
= 0; i
< SIZE
; i
++)
86 if (c
[i
] != a
[i
] + b
[i
])
88 if (a
[SIZE
] != SIZE
|| b
[SIZE
] != SIZE
|| c
[SIZE
] != SIZE
)
97 main (int argc
, const char **argv
)
103 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target avx2_runtime } } } */
104 /* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(MODE=V16QI\\)" 2 "vect" { target avx2_runtime } } } */