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 char a; 10 unsigned char b; 11 unsigned char c; 12 unsigned char d; 13 unsigned char e; 14 unsigned char f; 15 unsigned char g; 16 unsigned char h; 17 } s; 18 19 s check_res[N]; 20 21 __attribute__ ((noinline)) int main1(s * arr)22main1 (s *arr) 23 { 24 int i; 25 s *ptr = arr; 26 s res[N]; 27 unsigned char x; 28 29 for (i = 0; i < N; i++) 30 { 31 res[i].c = ptr->b + ptr->c; 32 x = ptr->c + ptr->f; 33 res[i].a = x + ptr->b; 34 res[i].d = ptr->b + ptr->c; 35 res[i].b = ptr->c; 36 res[i].f = ptr->f + ptr->e; 37 res[i].e = ptr->b + ptr->e; 38 res[i].h = ptr->c; 39 res[i].g = ptr->b + ptr->c; 40 ptr++; 41 } 42 43 /* check results: */ 44 for (i = 0; i < N; i++) 45 { 46 if (res[i].a != check_res[i].a 47 || res[i].b != check_res[i].b 48 || res[i].c != check_res[i].c 49 || res[i].d != check_res[i].d 50 || res[i].e != check_res[i].e 51 || res[i].f != check_res[i].f 52 || res[i].g != check_res[i].g 53 || res[i].h != check_res[i].h) 54 abort (); 55 } 56 57 ptr = arr; 58 /* Not vectorizable: gap in store. */ 59 for (i = 0; i < N; i++) 60 { 61 res[i].a = ptr->b; 62 res[i].b = ptr->c; 63 ptr++; 64 } 65 66 /* Check results. */ 67 for (i = 0; i < N; i++) 68 { 69 if (res[i].a != arr[i].b 70 || res[i].b != arr[i].c) 71 abort (); 72 } 73 74 } 75 76 main(void)77int main (void) 78 { 79 int i; 80 s arr[N]; 81 unsigned char x; 82 83 check_vect (); 84 85 for (i = 0; i < N; i++) 86 { 87 arr[i].a = i; 88 arr[i].b = i * 2; 89 arr[i].c = 17; 90 arr[i].d = i+34; 91 arr[i].e = i * 3 + 5; 92 arr[i].f = i * 5; 93 arr[i].g = i - 3; 94 arr[i].h = 56; 95 96 check_res[i].c = arr[i].b + arr[i].c; 97 x = arr[i].c + arr[i].f; 98 check_res[i].a = x + arr[i].b; 99 check_res[i].d = arr[i].b + arr[i].c; 100 check_res[i].b = arr[i].c; 101 check_res[i].f = arr[i].f + arr[i].e; 102 check_res[i].e = arr[i].b + arr[i].e; 103 check_res[i].h = arr[i].c; 104 check_res[i].g = arr[i].b + arr[i].c; 105 106 asm volatile ("" ::: "memory"); 107 } 108 main1 (arr); 109 110 return 0; 111 } 112 113 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_strided8 } } } */ 114 115