1 /* { dg-require-effective-target mmap } */
2
3 #include <sys/mman.h>
4 #include <stdio.h>
5 #include "tree-vect.h"
6
7 #define COUNT 320
8 #define MMAP_SIZE 0x10000
9 #define ADDRESS 0x1122000000
10 #define TYPE double
11
12 #ifndef MAP_ANONYMOUS
13 #define MAP_ANONYMOUS MAP_ANON
14 #endif
15
16 void __attribute__((noinline))
foo(TYPE * __restrict a,TYPE * __restrict b)17 foo (TYPE *__restrict a, TYPE *__restrict b)
18 {
19 int n;
20
21 b = __builtin_assume_aligned (b, sizeof (TYPE) * 2);
22 a = __builtin_assume_aligned (a, sizeof (TYPE) * 2);
23 for (n = 0; n < COUNT; n++)
24 {
25 a[n] = b[n * 4] + b[n * 4 + 1];
26 }
27 }
28
29 int
main(void)30 main (void)
31 {
32 void *x;
33 size_t b_offset;
34
35 check_vect ();
36
37 x = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE,
38 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
39 if (x == MAP_FAILED)
40 {
41 perror ("mmap");
42 return 1;
43 }
44
45 b_offset = MMAP_SIZE - (4 * COUNT - 2) * sizeof (TYPE);
46 foo ((TYPE *) x, (TYPE *) ((char *) x + b_offset));
47 return 0;
48 }
49