Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-strided-u16-i4.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 128 
7
8 typedef struct {
9    unsigned short a;
10    unsigned short b;
11    unsigned short c;
12    unsigned short d;
13 } s;
14
15 __attribute__ ((noinline)) int
16 main1 (s *arr)
17 {
18   int i;
19   s *ptr = arr;
20   s res[N];
21   unsigned short x, y, z, w;
22
23   for (i = 0; i < N; i++)
24     {
25       x = ptr->b - ptr->a;
26       y = ptr->d - ptr->c;
27       res[i].c = x + y;
28       z =  ptr->a + ptr->c;
29       w = ptr->b + ptr->d;
30       res[i].a = z + w;
31       res[i].d = x + y;
32       res[i].b = x + y;
33       ptr++;
34     }
35   
36   /* check results:  */
37   for (i = 0; i < N; i++)
38     {
39       if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c
40           || res[i].a != arr[i].a + arr[i].c + arr[i].b + arr[i].d
41           || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c
42           || res[i].b != arr[i].b - arr[i].a + arr[i].d - arr[i].c)
43         abort ();
44     }
45
46   return 0;
47 }
48
49 int main (void)
50 {
51   int i;
52   s arr[N];
53   
54   check_vect ();
55
56   for (i = 0; i < N; i++)
57     { 
58       arr[i].a = i;
59       arr[i].b = i * 2;
60       arr[i].c = 17;
61       arr[i].d = i+34;
62       if (arr[i].a == 178)
63          abort(); 
64     } 
65
66   main1 (arr);
67
68   return 0;
69 }
70
71 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target vect_strided4 } } } */
72 /* { dg-final { cleanup-tree-dump "vect" } } */
73