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     a[n] = b[n * 4];
25 }
26 
27 int
main(void)28 main (void)
29 {
30   void *x;
31   size_t b_offset;
32 
33   check_vect ();
34 
35   x = mmap ((void *) ADDRESS, MMAP_SIZE, PROT_READ | PROT_WRITE,
36 	    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
37   if (x == MAP_FAILED)
38     {
39       perror ("mmap");
40       return 1;
41     }
42 
43   b_offset = MMAP_SIZE - (4 * COUNT - 2) * sizeof (TYPE);
44   foo ((TYPE *) x, (TYPE *) ((char *) x + b_offset));
45   return 0;
46 }
47