| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
/* { dg-additional-options "--param max-completely-peel-times=1" } */ |
| 3 |
|
| 4 |
#include <stdarg.h> |
| 5 |
#include "tree-vect.h" |
| 6 |
|
| 7 |
#define N 16 |
| 8 |
|
| 9 |
unsigned short in[N]; |
| 10 |
|
| 11 |
__attribute__ ((noinline)) unsigned int |
| 12 |
foo (short scale){ |
| 13 |
int i; |
| 14 |
unsigned short j; |
| 15 |
unsigned int sum = 0; |
| 16 |
unsigned short sum_j; |
| 17 |
|
| 18 |
for (i = 0; i < N; i++) { |
| 19 |
sum_j = 0; |
| 20 |
for (j = 0; j < N; j++) { |
| 21 |
sum_j += j; |
| 22 |
} |
| 23 |
sum += ((unsigned int) in[i] * (unsigned int) sum_j) >> scale; |
| 24 |
} |
| 25 |
return sum; |
| 26 |
} |
| 27 |
|
| 28 |
__attribute__ ((noinline)) unsigned short |
| 29 |
bar (void) |
| 30 |
{ |
| 31 |
unsigned short j; |
| 32 |
unsigned short sum_j; |
| 33 |
sum_j = 0; |
| 34 |
for (j = 0; j < N; j++) { |
| 35 |
sum_j += j; |
| 36 |
} |
| 37 |
return sum_j; |
| 38 |
} |
| 39 |
|
| 40 |
int main (void) |
| 41 |
{ |
| 42 |
int i; |
| 43 |
unsigned short j, sum_j; |
| 44 |
unsigned int sum = 0; |
| 45 |
unsigned int res; |
| 46 |
|
| 47 |
check_vect (); |
| 48 |
|
| 49 |
for (i=0; i<N; i++){ |
| 50 |
in[i] = i; |
| 51 |
} |
| 52 |
|
| 53 |
res = foo (2); |
| 54 |
|
| 55 |
/* check results: */ |
| 56 |
for (i=0; i<N; i++) |
| 57 |
{ |
| 58 |
sum_j = bar (); |
| 59 |
sum += ((unsigned int) in[i] * (unsigned int) sum_j) >> 2; |
| 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" { target vect_widen_mult_hi_to_si } } } */ |