1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 16
7 #define DIFF 242
8
9 typedef struct {
10 unsigned char a;
11 unsigned char b;
12 unsigned char c;
13 unsigned char d;
14 } s;
15
16 unsigned char ub[N*2] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
17 unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
18
19 void
main1(unsigned char x,unsigned char max_result,unsigned char min_result,s * arr)20 main1 (unsigned char x, unsigned char max_result, unsigned char min_result, s *arr)
21 {
22 int i;
23 unsigned char udiff = 2;
24 unsigned char umax = x;
25 unsigned char umin = x;
26 unsigned char ua1[N*2];
27 s *pIn = arr;
28 s out[N];
29
30 for (i = 0; i < N; i++) {
31 udiff += (unsigned char)(ub[i] - uc[i]);
32
33 ua1[2*i+1] = ub[2*i+1];
34 ua1[2*i] = ub[2*i];
35
36 out[i].d = pIn->d - 1;
37 out[i].b = pIn->b - 4;
38 out[i].c = pIn->c - 8;
39 out[i].a = pIn->a - 3;
40
41 pIn++;
42 }
43
44 for (i = 0; i < N; i++) {
45 if (ua1[2*i] != ub[2*i]
46 || ua1[2*i+1] != ub[2*i+1]
47 || out[i].a != arr[i].a - 3
48 || out[i].b != arr[i].b - 4
49 || out[i].c != arr[i].c - 8
50 || out[i].d != arr[i].d - 1)
51 abort();
52 }
53
54 /* check results: */
55 if (udiff != DIFF)
56 abort ();
57 }
58
main(void)59 int main (void)
60 {
61 int i;
62 s arr[N];
63
64 for (i = 0; i < N; i++)
65 {
66 arr[i].a = i + 9;
67 arr[i].b = i * 2 + 10;
68 arr[i].c = 17;
69 arr[i].d = i+34;
70 asm volatile ("" ::: "memory");
71 }
72 check_vect ();
73
74 main1 (100, 100, 1, arr);
75 main1 (0, 15, 0, arr);
76 return 0;
77 }
78
79 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align && ilp32 } } } } */
80 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { xfail { vect_no_align && ilp32 } } } } */
81