Debian Codegraph @

gcc/testsuite/gcc.dg/vect/slp-perm-9.c

raw
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N (VECTOR_BITS * 6 / 16)
7
8 void __attribute__((noinline))
9 foo (unsigned short *__restrict__ pInput, unsigned short *__restrict__ pOutput)
10 {
11 unsigned short i, a, b, c;
12
13 for (i = 0; i < N / 3; i++)
14 {
15 a = *pInput++;
16 b = *pInput++;
17 c = *pInput++;
18
19 *pOutput++ = a + b + c + 3;
20 *pOutput++ = a + b + c + 12;
21 *pOutput++ = a + b + c + 1;
22 }
23 }
24
25 int main (int argc, const char* argv[])
26 {
27 unsigned short input[N], output[N], i;
28 unsigned short check_results[N];
29
30 check_vect ();
31
32 for (i = 0; i < N; i++)
33 {
34 input[i] = i;
35 output[i] = 0;
36 asm volatile ("" ::: "memory");
37 }
38
39 for (i = 0; i < N / 3; i++)
40 {
41 check_results[3*i] = 9 * i + 6;
42 check_results[3*i+1] = 9 * i + 15;
43 check_results[3*i+2] = 9 * i + 4;
44 __asm__ volatile ("" : : : "memory");
45 }
46
47 foo (input, output);
48
49 #pragma GCC novector
50 for (i = 0; i < N - (N % 3); i++)
51 if (output[i] != check_results[i])
52 abort ();
53
54 return 0;
55 }
56
57 /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" { target { ! { { vect_perm_short || vect32 } || vect_load_lanes } } } } } */
58 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { { vect_perm_short || vect32 } || vect_load_lanes } } } } */
59 /* We don't try permutes with a group size of 3 for variable-length
60 vectors. */
61 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { ! { vect_perm_short || { vect32 || vect_load_lanes } } } } } } */
62 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm_short || { vect32 || vect_load_lanes } } } } } */