PR target/55146
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-strided-u8-i8-gap4-unknown.c
blob7cfac72d7f11839366ddb2ba807cfe72d44fa076
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include <stdio.h>
5 #include "tree-vect.h"
7 #define N 160
9 typedef struct {
10 unsigned char a;
11 unsigned char b;
12 unsigned char c;
13 unsigned char d;
14 unsigned char e;
15 unsigned char f;
16 unsigned char g;
17 unsigned char h;
18 } s;
20 __attribute__ ((noinline)) int
21 main1 (s *arr, int n)
23 int i;
24 s *ptr = arr;
25 s res[N];
26 unsigned char x;
28 for (i = 0; i < N; i++)
30 res[i].a = 0;
31 res[i].b = 0;
32 res[i].c = 0;
33 res[i].d = 0;
34 res[i].e = 0;
35 res[i].f = 0;
36 res[i].g = 0;
37 res[i].h = 0;
38 __asm__ volatile ("");
41 /* Check peeling for gaps for unknown loop bound. */
42 for (i = 0; i < n; i++)
44 res[i].c = ptr->b + ptr->c;
45 x = ptr->c + ptr->f;
46 res[i].a = x + ptr->b;
47 res[i].d = ptr->b + ptr->c;
48 res[i].b = ptr->c;
49 res[i].f = ptr->f + ptr->e;
50 res[i].e = ptr->b + ptr->e;
51 res[i].h = ptr->c;
52 res[i].g = ptr->b + ptr->c;
53 ptr++;
56 /* check results: */
57 for (i = 0; i < n; i++)
59 if (res[i].c != arr[i].b + arr[i].c
60 || res[i].a != arr[i].c + arr[i].f + arr[i].b
61 || res[i].d != arr[i].b + arr[i].c
62 || res[i].b != arr[i].c
63 || res[i].f != arr[i].f + arr[i].e
64 || res[i].e != arr[i].b + arr[i].e
65 || res[i].h != arr[i].c
66 || res[i].g != arr[i].b + arr[i].c)
67 abort ();
70 /* Check also that we don't do more iterations than needed. */
71 for (i = n; i < N; i++)
73 if (res[i].c == arr[i].b + arr[i].c
74 || res[i].a == arr[i].c + arr[i].f + arr[i].b
75 || res[i].d == arr[i].b + arr[i].c
76 || res[i].b == arr[i].c
77 || res[i].f == arr[i].f + arr[i].e
78 || res[i].e == arr[i].b + arr[i].e
79 || res[i].h == arr[i].c
80 || res[i].g == arr[i].b + arr[i].c)
81 abort ();
84 return 0;
88 int main (void)
90 int i;
91 s arr[N];
93 check_vect ();
95 for (i = 0; i < N; i++)
97 arr[i].a = 5;
98 arr[i].b = 6;
99 arr[i].c = 17;
100 arr[i].d = 3;
101 arr[i].e = 16;
102 arr[i].f = 16;
103 arr[i].g = 3;
104 arr[i].h = 56;
105 if (arr[i].a == 178)
106 abort();
109 main1 (arr, N-2);
111 return 0;
114 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */
115 /* { dg-final { cleanup-tree-dump "vect" } } */