| 1 |
/* { dg-require-effective-target vect_float } */ |
| 2 |
/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ |
| 3 |
|
| 4 |
#include <stdarg.h> |
| 5 |
#include "tree-vect.h" |
| 6 |
|
| 7 |
#define N 16 |
| 8 |
|
| 9 |
float b[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; |
| 10 |
float a[N]; |
| 11 |
float c[N]; |
| 12 |
|
| 13 |
__attribute__ ((noinline)) |
| 14 |
int main1 (int n) |
| 15 |
{ |
| 16 |
int i=0; |
| 17 |
|
| 18 |
/* Vectorized: unknown loop bound. */ |
| 19 |
while (n--) { |
| 20 |
a[i] = b[i]; |
| 21 |
i++; |
| 22 |
} |
| 23 |
|
| 24 |
/* check results: */ |
| 25 |
#pragma GCC novector |
| 26 |
for (i = 0; i < n; i++) |
| 27 |
{ |
| 28 |
if (a[i] != b[i]) |
| 29 |
abort (); |
| 30 |
} |
| 31 |
|
| 32 |
return 0; |
| 33 |
} |
| 34 |
|
| 35 |
__attribute__ ((noinline)) |
| 36 |
int main2 (unsigned int n) |
| 37 |
{ |
| 38 |
int i=0; |
| 39 |
int nn = n; |
| 40 |
|
| 41 |
/* Vectorized: unknown loop bound. */ |
| 42 |
while (n--) { |
| 43 |
c[i] = b[i]; |
| 44 |
i++; |
| 45 |
} |
| 46 |
|
| 47 |
/* check results: */ |
| 48 |
#pragma GCC novector |
| 49 |
for (i = 0; i < nn; i++) |
| 50 |
{ |
| 51 |
if (c[i] != b[i]) |
| 52 |
abort (); |
| 53 |
} |
| 54 |
|
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
int main (void) |
| 59 |
{ |
| 60 |
check_vect (); |
| 61 |
|
| 62 |
main1 (N); |
| 63 |
main2 (N); |
| 64 |
return 0; |
| 65 |
} |
| 66 |
|
| 67 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */ |
| 68 |
/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ |