| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
/* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */ |
| 3 |
|
| 4 |
#include <stdlib.h> |
| 5 |
#include <stdarg.h> |
| 6 |
#include "tree-vect.h" |
| 7 |
|
| 8 |
#define N 4 |
| 9 |
|
| 10 |
struct extraction |
| 11 |
{ |
| 12 |
int a[N][N]; |
| 13 |
int b[N][N]; |
| 14 |
}; |
| 15 |
|
| 16 |
static int a[N][N] = {{1,2,3,11},{4,5,6,12},{7,8,9,13},{34,45,67,83}}; |
| 17 |
static int b[N][N] = {{17,28,15,23},{0,2,3,24},{4,31,82,25},{29,31,432,256}}; |
| 18 |
static int c[N][N] = {{1,2,3,11},{4,9,13,34},{45,67,83,13},{34,45,67,83}}; |
| 19 |
|
| 20 |
__attribute__ ((noinline)) |
| 21 |
int main1 (int x) { |
| 22 |
int i,j; |
| 23 |
struct extraction *p; |
| 24 |
p = (struct extraction *) malloc (sizeof (struct extraction)); |
| 25 |
|
| 26 |
for (i = 0; i < N; i++) |
| 27 |
{ |
| 28 |
for (j = 0; j < N; j++) |
| 29 |
{ |
| 30 |
p->a[i][j] = a[i][j]; |
| 31 |
p->b[i][j] = b[i][j]; |
| 32 |
asm volatile ("" ::: "memory"); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
/* Vectorizable: distance > number of iterations. */ |
| 37 |
for (i = 1; i < N; i++) |
| 38 |
{ |
| 39 |
#pragma GCC unroll 0 |
| 40 |
for (j = 0; j < N; j++) |
| 41 |
{ |
| 42 |
*((int *)p + x + i + j) = *((int *)p + x + i + j + 5); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
/* check results: */ |
| 47 |
for (i = 0; i < N; i++) |
| 48 |
{ |
| 49 |
#pragma GCC novector |
| 50 |
for (j = 0; j < N; j++) |
| 51 |
{ |
| 52 |
if (p->a[i][j] != c[i][j]) |
| 53 |
abort(); |
| 54 |
} |
| 55 |
} |
| 56 |
return 0; |
| 57 |
} |
| 58 |
|
| 59 |
int main (void) |
| 60 |
{ |
| 61 |
check_vect (); |
| 62 |
|
| 63 |
return main1 (N); |
| 64 |
} |
| 65 |
|
| 66 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ |
| 67 |
/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */ |
| 68 |
/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */ |
| 69 |
|
| 70 |
/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ |