1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */
3 
4 void foo(char *);
my_memcpy(void * q,unsigned int n)5 void my_memcpy (void *q, unsigned int n)
6 {
7   unsigned i;
8   char p[1024];
9   for (i = 0; i < n; ++i)
10     ((char *)p)[i] = ((char *)q)[i];
11   foo(p);
12 }
13 
14 struct S { int i; int j; };
15 
my_memcpy2(void * q,unsigned int n)16 void my_memcpy2 (void *q, unsigned int n)
17 {
18   unsigned i;
19   char p[1024];
20   for (i = 0; i < n; ++i)
21     ((struct S *)p)[i] = ((struct S *)q)[i];
22   foo(p);
23 }
24 
25 char p[1024];
my_memmove(unsigned int n)26 void my_memmove (unsigned int n)
27 {
28   unsigned i;
29   for (i = 0; i < n; ++i)
30     p[i] = p[i+1];
31   foo(p);
32 }
33 
34 
35 /* { dg-final { scan-tree-dump-times "generated memcpy" 2 "ldist" } } */
36 /* { dg-final { scan-tree-dump-times "generated memmove" 1 "ldist" } } */
37