OSDN Git Service

PR tree-optimization/52019
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / pr29215.c
1 /* PR middle-end/29215 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-gimple" } */
4
5 char buf[5 * sizeof (int) + 1] __attribute__((aligned (__alignof__ (int))));
6
7 static void
8 foo (int arg1, int arg2, int arg3, int arg4, int arg5)
9 {
10   __builtin_memcpy (buf, &arg1, sizeof (int));
11   __builtin_memcpy (buf + sizeof (int), &arg2, sizeof (int));
12   __builtin_memcpy (buf + 2 * sizeof (int), &arg3, sizeof (int));
13   __builtin_memcpy (buf + 3 * sizeof (int), &arg4, sizeof (int));
14   __builtin_memcpy (buf + 4 * sizeof (int), &arg5, sizeof (int));
15 }
16
17 int
18 main (void)
19 {
20   union { char buf[4]; int i; } u;
21   u.i = 0;
22   u.buf[0] = 'a';
23   u.buf[1] = 'b';
24   u.buf[2] = 'c';
25   u.buf[3] = 'd';
26   foo (u.i, u.i, u.i, u.i, u.i);
27   buf[5 * sizeof (int)] = '\0';
28   __builtin_puts (buf);
29   return 0;
30 }
31
32 /* { dg-final { scan-tree-dump-not "memcpy" "gimple" } } */
33 /* { dg-final { cleanup-tree-dump "gimple" } } */