Add compile command to each testcase
[gcc-vect-testsuite.git] / vect-strided-u16-i3.c
blobe423148407d47ac157bdf4f5524d327257596ccb
1 #include <stdarg.h>
2 #include "tree-vect.h"
4 #define N 128
6 typedef struct {
7 unsigned short a;
8 unsigned short b;
9 unsigned short c;
10 } s;
12 #define A(I) (I)
13 #define B(I) ((I) * 2)
14 #define C(I) ((unsigned short) ~((I) ^ 0x18))
16 void __attribute__ ((noinline))
17 check1 (s *res)
19 int i;
21 for (i = 0; i < N; i++)
22 if (res[i].a != C (i)
23 || res[i].b != A (i)
24 || res[i].c != B (i))
25 abort ();
28 void __attribute__ ((noinline))
29 check2 (unsigned short *res)
31 int i;
33 for (i = 0; i < N; i++)
34 if (res[i] != (unsigned short) (A (i) + B (i) + C (i)))
35 abort ();
38 void __attribute__ ((noinline))
39 check3 (s *res)
41 int i;
43 for (i = 0; i < N; i++)
44 if (res[i].a != i
45 || res[i].b != i
46 || res[i].c != i)
47 abort ();
50 void __attribute__ ((noinline))
51 check4 (unsigned short *res)
53 int i;
55 for (i = 0; i < N; i++)
56 if (res[i] != (unsigned short) (A (i) + B (i)))
57 abort ();
60 void __attribute__ ((noinline))
61 main1 (s *arr)
63 int i;
64 s *ptr = arr;
65 s res1[N];
66 unsigned short res2[N];
68 for (i = 0; i < N; i++)
70 res1[i].a = arr[i].c;
71 res1[i].b = arr[i].a;
72 res1[i].c = arr[i].b;
74 check1 (res1);
76 for (i = 0; i < N; i++)
77 res2[i] = arr[i].a + arr[i].b + arr[i].c;
78 check2 (res2);
80 for (i = 0; i < N; i++)
82 res1[i].a = i;
83 res1[i].b = i;
84 res1[i].c = i;
86 check3 (res1);
88 for (i = 0; i < N; i++)
89 res2[i] = arr[i].a + arr[i].b;
90 check4 (res2);
93 int main (void)
95 int i;
96 s arr[N];
98 check_vect ();
100 for (i = 0; i < N; i++)
102 arr[i].a = A (i);
103 arr[i].b = B (i);
104 arr[i].c = C (i);
106 main1 (arr);
108 return 0;
111 /* { dg-final { scan-tree-dump-times "vectorized 4 loops" 1 "vect" { target vect_strided3 } } } */
112 /* { dg-final { cleanup-tree-dump "vect" } } */