Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-strided-u16-i4.c

raw
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 #pragma GCC novector
38 for (i = 0; i < N; i++)
39 {
40 if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c
41 || res[i].a != arr[i].a + arr[i].c + arr[i].b + arr[i].d
42 || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c
43 || res[i].b != arr[i].b - arr[i].a + arr[i].d - arr[i].c)
44 abort ();
45 }
46
47 return 0;
48 }
49
50 int main (void)
51 {
52 int i;
53 s arr[N];
54
55 check_vect ();
56
57 for (i = 0; i < N; i++)
58 {
59 arr[i].a = i;
60 arr[i].b = i * 2;
61 arr[i].c = 17;
62 arr[i].d = i+34;
63 asm volatile ("" ::: "memory");
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