1 /* { dg-require-effective-target vect_int } */ 2 3 #include <stdarg.h> 4 #include "tree-vect.h" 5 6 #define N 40 7 8 int a[N]; 9 int b[N]; 10 int c[N]; 11 12 __attribute__ ((noinline)) int foo()13foo (){ 14 int i; 15 unsigned short j; 16 int sum = 0; 17 unsigned short sum_j; 18 19 for (i = 0; i < N; i++) { 20 int diff = b[i] - c[i]; 21 22 sum_j = 0; 23 for (j = 0; j < N; j++) { 24 sum_j += j; 25 } 26 a[i] = sum_j + 5; 27 28 sum += diff; 29 } 30 return sum; 31 } 32 main(void)33int main (void) 34 { 35 int i; 36 unsigned short j, sum_j; 37 int sum = 0; 38 int res; 39 40 check_vect (); 41 42 for (i=0; i<N; i++){ 43 b[i] = i; 44 c[i] = 2*i; 45 } 46 47 res = foo (); 48 49 /* check results: */ 50 for (i=0; i<N; i++) 51 { 52 sum += (b[i] - c[i]); 53 54 sum_j = 0; 55 for (j = 0; j < N; j++){ 56 sum_j += j; 57 } 58 if (a[i] != sum_j + 5) 59 abort(); 60 } 61 if (res != sum) 62 abort (); 63 64 return 0; 65 } 66 67 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail { ! {vect_unpack } } } } } */ 68