PR target/55146
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-24-big-array.c
blob6c8f01c97497abc4862c77dff715bae77146fcea
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 64
8 typedef struct {
9 unsigned char a;
10 unsigned char b;
11 unsigned char c;
12 unsigned char d;
13 } s;
15 unsigned char ub[N*2];
16 unsigned char uc[N];
18 volatile int y = 0;
19 unsigned char check_diff = 2;
21 void
22 main1 (unsigned char x, unsigned char max_result, unsigned char min_result, s *arr)
24 int i;
25 unsigned char udiff = 2;
26 unsigned char umax = x;
27 unsigned char umin = x;
28 unsigned char ua1[N*2];
29 s *pIn = arr;
30 s out[N];
32 for (i = 0; i < N; i++) {
33 udiff += (unsigned char) (ub[i] - uc[i]);
35 ua1[2*i+1] = ub[2*i+1];
36 ua1[2*i] = ub[2*i];
38 out[i].d = pIn->d - 1;
39 out[i].b = pIn->b - 4;
40 out[i].c = pIn->c - 8;
41 out[i].a = pIn->a - 3;
43 pIn++;
46 for (i = 0; i < N; i++) {
47 if (ua1[2*i] != ub[2*i]
48 || ua1[2*i+1] != ub[2*i+1]
49 || out[i].a != arr[i].a - 3
50 || out[i].b != arr[i].b - 4
51 || out[i].c != arr[i].c - 8
52 || out[i].d != arr[i].d - 1)
53 abort ();
56 /* check results: */
57 if (udiff != check_diff)
58 abort ();
61 int main (void)
63 int i;
64 s arr[N];
66 check_diff = 2;
67 ub[0] = uc[0] = 1;
68 for (i = 1; i < N; i++) {
69 ub[i] = (i%5 == 0)?i*3:i;
70 uc[i] = i;
71 check_diff += (unsigned char) (ub[i] - uc[i]);
72 if (y) /* Avoid vectorization. */
73 abort ();
75 for (; i < 2*N; i++) {
76 ub[i] = 0;
77 if (y) /* Avoid vectorization. */
78 abort ();
81 for (i = 0; i < N; i++)
83 arr[i].a = i + 9;
84 arr[i].b = i * 2 + 10;
85 arr[i].c = 17;
86 arr[i].d = i+34;
87 if (arr[i].a == 178)
88 abort ();
90 check_vect ();
92 main1 (100, 100, 1, arr);
93 main1 (0, 15, 0, arr);
94 return 0;
97 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && ilp32 } } } } */
98 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail { vect_no_align && ilp32 } } } } */
99 /* { dg-final { cleanup-tree-dump "vect" } } */