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 volatile int y = 0; 16 17 __attribute__ ((noinline)) int main1()18main1 () 19 { 20 s arr[N]; 21 s *ptr = arr; 22 s res[N]; 23 int i; 24 25 for (i = 0; i < N; i++) 26 { 27 arr[i].a = i; 28 arr[i].b = i * 2; 29 arr[i].c = 17; 30 arr[i].d = i+34; 31 if (y) /* Avoid vectorization. */ 32 abort (); 33 } 34 35 for (i = 0; i < N; i++) 36 { 37 unsigned short x, y, z, w; 38 x = ptr->b - ptr->a; 39 y = ptr->d - ptr->c; 40 res[i].c = x + y; 41 z = ptr->a + ptr->c; 42 w = ptr->b + ptr->d; 43 res[i].a = z + w; 44 res[i].d = x + y; 45 res[i].b = x + y; 46 ptr++; 47 } 48 49 /* check results: */ 50 for (i = 0; i < N; i++) 51 { 52 if (res[i].c != arr[i].b - arr[i].a + arr[i].d - arr[i].c 53 || res[i].a != arr[i].a + arr[i].c + arr[i].b + arr[i].d 54 || res[i].d != arr[i].b - arr[i].a + arr[i].d - arr[i].c 55 || res[i].b != arr[i].b - arr[i].a + arr[i].d - arr[i].c) 56 abort (); 57 } 58 59 return 0; 60 } 61 main(void)62int main (void) 63 { 64 int i; 65 66 check_vect (); 67 68 main1 (); 69 70 return 0; 71 } 72 73 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided4 } } } */ 74 75