1 /* { dg-do run } */
2 /* { dg-require-effective-target store_merge } */
3 /* { dg-options "-O2 -fdump-tree-store-merging" } */
4 
5 struct S { unsigned char b[2]; unsigned short c; unsigned char d[4]; unsigned long e; };
6 
7 __attribute__((noipa)) void
foo(struct S * p)8 foo (struct S *p)
9 {
10   p->b[1] = 1;
11   p->c = 23;
12   p->d[0] = 4;
13   p->d[1] = 5;
14   p->d[2] = 6;
15   p->d[3] = 7;
16   p->e = 8;
17 }
18 
19 __attribute__((noipa)) void
bar(struct S * p)20 bar (struct S *p)
21 {
22   p->b[1] = 9;
23   p->c = 112;
24   p->d[0] = 10;
25   p->d[1] = 11;
26 }
27 
28 struct S s = { { 30, 31 }, 32, { 33, 34, 35, 36 }, 37 };
29 
30 int
main()31 main ()
32 {
33   asm volatile ("" : : : "memory");
34   foo (&s);
35   asm volatile ("" : : : "memory");
36   if (s.b[0] != 30 || s.b[1] != 1 || s.c != 23 || s.d[0] != 4 || s.d[1] != 5
37       || s.d[2] != 6 || s.d[3] != 7 || s.e != 8)
38     __builtin_abort ();
39   bar (&s);
40   asm volatile ("" : : : "memory");
41   if (s.b[0] != 30 || s.b[1] != 9 || s.c != 112 || s.d[0] != 10 || s.d[1] != 11
42       || s.d[2] != 6 || s.d[3] != 7 || s.e != 8)
43     __builtin_abort ();
44   return 0;
45 }
46 
47 /* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */
48