PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-perm-9.c
blobb01d493b6e73e4700d5e4bf7137de4a3848c1f92
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #if VECTOR_BITS > 512
7 #define N (VECTOR_BITS * 6 / 16)
8 #else
9 #define N 200
10 #endif
12 void __attribute__((noinline))
13 foo (unsigned short *__restrict__ pInput, unsigned short *__restrict__ pOutput)
15 unsigned short i, a, b, c;
17 for (i = 0; i < N / 3; i++)
19 a = *pInput++;
20 b = *pInput++;
21 c = *pInput++;
23 *pOutput++ = a + b + c + 3;
24 *pOutput++ = a + b + c + 12;
25 *pOutput++ = a + b + c + 1;
29 int main (int argc, const char* argv[])
31 unsigned short input[N], output[N], i;
32 unsigned short check_results[N];
34 check_vect ();
36 for (i = 0; i < N; i++)
38 input[i] = i;
39 output[i] = 0;
40 asm volatile ("" ::: "memory");
43 for (i = 0; i < N / 3; i++)
45 check_results[3*i] = 9 * i + 6;
46 check_results[3*i+1] = 9 * i + 15;
47 check_results[3*i+2] = 9 * i + 4;
48 __asm__ volatile ("" : : : "memory");
51 foo (input, output);
53 for (i = 0; i < N - (N % 3); i++)
54 if (output[i] != check_results[i])
55 abort ();
57 return 0;
60 /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" { target { ! { vect_perm_short || vect_load_lanes } } } } } */
61 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { vect_perm_short || vect_load_lanes } } } } */
62 /* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 1 "vect" { target { vect_perm_short && { ! vect_perm3_short } } } } } */
63 /* { dg-final { scan-tree-dump-not "permutation requires at least three vectors" "vect" { target vect_perm3_short } } } */
64 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { { ! vect_perm3_short } || vect_load_lanes } } } } */
65 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { vect_perm3_short && { ! vect_load_lanes } } } } } */