Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / pr45752.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define M00 100
7 #define M10 216
8 #define M20 23
9 #define M30 237
10 #define M40 437
11
12 #define M01 1322
13 #define M11 13
14 #define M21 27271
15 #define M31 2280
16 #define M41 284
17
18 #define M02 74
19 #define M12 191
20 #define M22 500
21 #define M32 111
22 #define M42 1114
23
24 #define M03 134
25 #define M13 117
26 #define M23 11
27 #define M33 771
28 #define M43 71
29
30 #define M04 334
31 #define M14 147
32 #define M24 115
33 #define M34 7716
34 #define M44 16
35
36 #define N 16
37
38 void foo (unsigned int *__restrict__ pInput,
39           unsigned int *__restrict__ pOutput,
40           unsigned int *__restrict__ pInput2,
41           unsigned int *__restrict__ pOutput2)
42 {
43   unsigned int i, a, b, c, d, e;
44
45   for (i = 0; i < N / 5; i++)
46     {
47        a = *pInput++;
48        b = *pInput++;
49        c = *pInput++;
50        d = *pInput++;
51        e = *pInput++;
52
53        *pOutput++ = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e;
54        *pOutput++ = M10 * a + M11 * b + M12 * c + M13 * d + M14 * e;
55        *pOutput++ = M20 * a + M21 * b + M22 * c + M23 * d + M24 * e;
56        *pOutput++ = M30 * a + M31 * b + M32 * c + M33 * d + M34 * e;
57        *pOutput++ = M40 * a + M41 * b + M42 * c + M43 * d + M44 * e;
58
59
60        a = *pInput2++;
61        b = *pInput2++;
62        c = *pInput2++;
63        d = *pInput2++;
64        e = *pInput2++;
65
66        *pOutput2++ = M00 * a + M01 * b + M02 * c + M03 * d + M04 * e;
67        *pOutput2++ = M10 * a + M11 * b + M12 * c + M13 * d + M14 * e;
68        *pOutput2++ = M20 * a + M21 * b + M22 * c + M23 * d + M24 * e;
69        *pOutput2++ = M30 * a + M31 * b + M32 * c + M33 * d + M34 * e;
70        *pOutput2++ = M40 * a + M41 * b + M42 * c + M43 * d + M44 * e;
71
72     }
73 }
74
75 int main (int argc, const char* argv[])
76 {
77   unsigned int input[N], output[N], i, input2[N], output2[N];
78   unsigned int check_results[N] = {3208, 1334, 28764, 35679, 2789, 13028,
79     4754, 168364, 91254, 12399, 22848, 8174, 307964, 146829, 22009, 0};
80   unsigned int check_results2[N] = {7136, 2702, 84604, 57909, 6633, 16956,
81     6122, 224204, 113484, 16243, 26776, 9542, 363804, 169059, 25853, 0};
82
83   check_vect ();
84
85   for (i = 0; i < N; i++)
86     {
87       input[i] = i%256;
88       input2[i] = i + 2;
89       output[i] = 0;
90       output2[i] = 0;
91       __asm__ volatile ("");
92     }
93
94   foo (input, output, input2, output2);
95
96   for (i = 0; i < N; i++)
97     if (output[i] != check_results[i]
98         || output2[i] != check_results2[i])
99       abort ();
100
101   return 0;
102 }
103
104 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect"  } } */
105 /* { dg-final { scan-tree-dump "permutation requires at least three vectors" "vect" { target vect_perm } } } */
106 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect"  } } */
107 /* { dg-final { cleanup-tree-dump "vect" } } */
108