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