libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-gather-3.c
blob30ba6789e0382d8c8e0be9da3cb64931dff6cdb4
1 #include "tree-vect.h"
3 #define N 16
5 void __attribute__((noipa))
6 f (int *restrict y, int *restrict x, int *restrict indices)
8 for (int i = 0; i < N; ++i)
10 y[i * 2] = (indices[i * 2] < N * 2
11 ? x[indices[i * 2]] + 1
12 : 1);
13 y[i * 2 + 1] = (indices[i * 2 + 1] < N * 2
14 ? x[indices[i * 2 + 1]] + 2
15 : 2);
19 int y[N * 2];
20 int x[N * 2] = {
21 72704, 52152, 51301, 96681,
22 57937, 60490, 34504, 60944,
23 42225, 28333, 88336, 74300,
24 29250, 20484, 38852, 91536,
25 86917, 63941, 31590, 21998,
26 22419, 26974, 28668, 13968,
27 3451, 20247, 44089, 85521,
28 22871, 87362, 50555, 85939
30 int indices[N * 2] = {
31 15, 0x10000, 0xcafe0, 19,
32 7, 22, 19, 1,
33 0x20000, 0x70000, 15, 30,
34 5, 12, 11, 11,
35 10, 25, 5, 20,
36 22, 24, 32, 28,
37 30, 19, 6, 0xabcdef,
38 7, 12, 8, 21
40 int expected[N * 2] = {
41 91537, 2, 1, 22000,
42 60945, 28670, 21999, 52154,
43 1, 2, 91537, 50557,
44 60491, 29252, 74301, 74302,
45 88337, 20249, 60491, 22421,
46 28669, 3453, 1, 22873,
47 50556, 22000, 34505, 2,
48 60945, 29252, 42226, 26976
51 int
52 main (void)
54 check_vect ();
56 f (y, x, indices);
57 #pragma GCC novector
58 for (int i = 0; i < 32; ++i)
59 if (y[i] != expected[i])
60 __builtin_abort ();
62 return 0;
65 /* { dg-final { scan-tree-dump "Loop contains only SLP stmts" vect { target { { vect_gather_load_ifn || avx2 } && vect_masked_load } } } } */