2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-23.c
blob3cda497db0cd5331ad0b6156512a4972a64b4fa0
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 128
8 typedef struct {
9 int a;
10 int b;
11 int c;
12 int d;
13 int e;
14 int f;
15 int g;
16 int h;
17 } s;
19 int
20 main1 (s *arr)
22 int i;
23 s *ptr = arr;
24 s res[N];
26 for (i = 0; i < N; i++)
28 res[i].c = ptr->c + ptr->c;
29 res[i].a = ptr->a + ptr->a;
30 res[i].d = ptr->d + ptr->d;
31 res[i].b = ptr->b + ptr->b;
32 res[i].f = ptr->f + ptr->f;
33 res[i].e = ptr->e + ptr->e;
34 res[i].h = ptr->h + ptr->h;
35 res[i].g = ptr->g + ptr->g;
36 ptr++;
39 /* check results: */
40 for (i = 0; i < N; i++)
42 if (res[i].c != arr[i].c + arr[i].c
43 || res[i].a != arr[i].a + arr[i].a
44 || res[i].d != arr[i].d + arr[i].d
45 || res[i].b != arr[i].b + arr[i].b
46 || res[i].f != arr[i].f + arr[i].f
47 || res[i].e != arr[i].e + arr[i].e
48 || res[i].h != arr[i].h + arr[i].h
49 || res[i].g != arr[i].g + arr[i].g)
50 abort();
53 ptr = arr;
54 for (i = 0; i < N; i++)
56 res[i].c = ptr->c + ptr->c;
57 res[i].a = ptr->a + ptr->a;
58 res[i].d = ptr->d + ptr->d;
59 res[i].b = ptr->b + ptr->b;
60 res[i].f = ptr->f + ptr->f;
61 res[i].e = ptr->e + ptr->e;
62 res[i].h = ptr->e + ptr->e;
63 res[i].g = ptr->g + ptr->g;
64 ptr++;
67 /* check results: */
68 for (i = 0; i < N; i++)
70 if (res[i].c != arr[i].c + arr[i].c
71 || res[i].a != arr[i].a + arr[i].a
72 || res[i].d != arr[i].d + arr[i].d
73 || res[i].b != arr[i].b + arr[i].b
74 || res[i].f != arr[i].f + arr[i].f
75 || res[i].e != arr[i].e + arr[i].e
76 || res[i].h != arr[i].e + arr[i].e
77 || res[i].g != arr[i].g + arr[i].g)
78 abort();
83 int main (void)
85 int i;
86 s arr[N];
88 check_vect ();
90 for (i = 0; i < N; i++)
92 arr[i].a = i;
93 arr[i].b = i * 2;
94 arr[i].c = 17;
95 arr[i].d = i+34;
96 arr[i].e = i * 3 + 5;
97 arr[i].f = i * 5;
98 arr[i].g = i - 3;
99 arr[i].h = 56;
100 asm volatile ("" ::: "memory");
103 main1 (arr);
105 return 0;
108 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { target { vect_strided8 && { ! { vect_no_align} } } } } } */
109 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target { ! { vect_strided8 || vect_no_align } } } } } */
110 /* We fail to vectorize the second loop with variable-length SVE but
111 fall back to 128-bit vectors, which does use SLP. */
112 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { ! vect_perm } } } } */
113 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect" { target vect_perm } } } */