| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#define N 40 |
| 7 |
|
| 8 |
__attribute__ ((noinline)) int |
| 9 |
foo (int * __restrict__ b, int k){ |
| 10 |
int i,j; |
| 11 |
int sum,x; |
| 12 |
int a[N]; |
| 13 |
|
| 14 |
for (i = 0; i < N; i++) { |
| 15 |
sum = b[i]; |
| 16 |
for (j = 0; j < N; j++) { |
| 17 |
sum += j; |
| 18 |
} |
| 19 |
a[i] = sum; |
| 20 |
} |
| 21 |
|
| 22 |
return a[k]; |
| 23 |
} |
| 24 |
|
| 25 |
int main (void) |
| 26 |
{ |
| 27 |
int i,j; |
| 28 |
int sum; |
| 29 |
int b[N]; |
| 30 |
int a[N]; |
| 31 |
|
| 32 |
check_vect (); |
| 33 |
|
| 34 |
for (i=0; i<N; i++) |
| 35 |
b[i] = i + 2; |
| 36 |
|
| 37 |
for (i=0; i<N; i++) |
| 38 |
a[i] = foo (b,i); |
| 39 |
|
| 40 |
/* check results: */ |
| 41 |
#pragma GCC novector |
| 42 |
for (i=0; i<N; i++) |
| 43 |
{ |
| 44 |
sum = b[i]; |
| 45 |
for (j = 0; j < N; j++){ |
| 46 |
sum += j; |
| 47 |
} |
| 48 |
if (a[i] != sum) |
| 49 |
abort(); |
| 50 |
} |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |
| 54 |
|
| 55 |
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail { unaligned_stack || { vect_no_align && { ! vect_hw_misalign } } } } } } */ |
| 56 |
/* Exclude widening of i * 4 in the calculation of a[i]. */ |
| 57 |
/* { dg-final { scan-tree-dump-times {vect_recog_widen_mult_pattern: detected: [^\n]* \* ([^4]|4[^;])} 1 "vect" { xfail *-*-* } } } */ |