libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-strided-a-mult.c
blob1531553651ceb6185ce16ab49f447496ad923408
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 128
8 typedef struct {
9 unsigned short a;
10 unsigned short b;
11 } s;
13 typedef struct {
14 unsigned int a;
15 unsigned int b;
16 } ii;
18 __attribute__ ((noinline)) int
19 main1 ()
21 s arr[N];
22 s *ptr = arr;
23 ii iarr[N];
24 ii *iptr = iarr;
25 s res[N];
26 ii ires[N];
27 int i;
29 for (i = 0; i < N; i++)
31 arr[i].a = i;
32 arr[i].b = i * 2;
33 iarr[i].a = i;
34 iarr[i].b = i * 3;
35 asm volatile ("" ::: "memory");
38 for (i = 0; i < N; i++)
40 ires[i].a = iptr->b - iptr->a;
41 ires[i].b = iptr->b + iptr->a;
42 res[i].b = ptr->b - ptr->a;
43 res[i].a = ptr->b + ptr->a;
44 iptr++;
45 ptr++;
48 /* check results: */
49 #pragma GCC novector
50 for (i = 0; i < N; i++)
52 if (res[i].b != arr[i].b - arr[i].a
53 || ires[i].a != iarr[i].b - iarr[i].a
54 || res[i].a != arr[i].b + arr[i].a
55 || ires[i].b != iarr[i].b + iarr[i].a
57 abort ();
60 return 0;
63 int main (void)
65 int i;
67 check_vect ();
69 main1 ();
71 return 0;
74 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided2 } } } */