i386: Adjust rtx cost for imulq and imulw [PR115749]
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr87288-2.c
blob03c7f88a6a48507bbbfbf2e177425d28605a3aa6
1 #include "tree-vect.h"
3 #define N (VECTOR_BITS / 32)
4 #define MAX_COUNT 4
6 #define RUN_COUNT(COUNT) \
7 void __attribute__ ((noipa)) \
8 run_##COUNT (int *restrict a, int *restrict b) \
9 { \
10 for (int i = 0; i < N * COUNT; ++i) \
11 { \
12 a[i * 2] = b[i * 2] + COUNT; \
13 a[i * 2 + 1] = COUNT; \
14 } \
17 RUN_COUNT (1)
18 RUN_COUNT (2)
19 RUN_COUNT (3)
20 RUN_COUNT (4)
22 void __attribute__ ((noipa))
23 check (int *restrict a, int count)
25 #pragma GCC novector
26 for (int i = 0; i < count * N; ++i)
27 if (a[i * 2] != i * 41 + count || a[i * 2 + 1] != count)
28 __builtin_abort ();
29 if (a[count * 2 * N] != 999)
30 __builtin_abort ();
33 int a[N * MAX_COUNT * 2 + 1], b[N * MAX_COUNT * 2];
35 int
36 main (void)
38 check_vect ();
40 for (int i = 0; i < N * MAX_COUNT; ++i)
42 b[i * 2] = i * 41;
43 asm volatile ("" ::: "memory");
46 a[N * 2] = 999;
47 run_1 (a, b);
48 check (a, 1);
50 a[N * 4] = 999;
51 run_2 (a, b);
52 check (a, 2);
54 a[N * 6] = 999;
55 run_3 (a, b);
56 check (a, 3);
58 a[N * 8] = 999;
59 run_4 (a, b);
60 check (a, 4);
62 return 0;
65 /* { dg-final { scan-tree-dump {LOOP VECTORIZED} "vect" { target { { vect_int && vect_perm } && vect_element_align } } } } */