| 1 |
/* { dg-require-effective-target vect_int_mult } */ |
| 2 |
#include <stdarg.h> |
| 3 |
#include "tree-vect.h" |
| 4 |
|
| 5 |
#define N 16 |
| 6 |
|
| 7 |
__attribute__ ((noinline)) int main1 (int X) |
| 8 |
{ |
| 9 |
int arr1[N+1]; |
| 10 |
int arr2[N+1]; |
| 11 |
int k = X; |
| 12 |
int m, i=0; |
| 13 |
|
| 14 |
/* Vectorization of induction with non-constant initial condition X. |
| 15 |
Also we have here two uses of the induction-variable k as defined |
| 16 |
by the loop-header phi (as opposed to the other uses of k that are |
| 17 |
defined in the loop), in which case we exercise the fact that we |
| 18 |
reuse the same vector def-use-cycle for both uses. |
| 19 |
Peeling to align the store is also applied. This peeling also aligns |
| 20 |
the load (as they have the same misalignment). */ |
| 21 |
|
| 22 |
do { |
| 23 |
arr2[i+1] = 2*k; |
| 24 |
k = k + 2; |
| 25 |
arr1[i+1] = k; |
| 26 |
k = k + 4; |
| 27 |
i++; |
| 28 |
} while (i < N); |
| 29 |
|
| 30 |
/* check results: */ |
| 31 |
#pragma GCC novector |
| 32 |
for (i = 0; i < N; i++) |
| 33 |
{ |
| 34 |
if (arr1[i+1] != X+6*i+2 |
| 35 |
|| arr2[i+1] != 2*(X+6*i)) |
| 36 |
abort (); |
| 37 |
} |
| 38 |
|
| 39 |
return 0; |
| 40 |
} |
| 41 |
|
| 42 |
int main (void) |
| 43 |
{ |
| 44 |
check_vect (); |
| 45 |
|
| 46 |
return main1 (3); |
| 47 |
} |
| 48 |
|
| 49 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ |