1 /* { dg-do run } */
2 /* { dg-require-effective-target store_merge } */
3 /* { dg-options "-O2 -fdump-tree-store-merging" } */
4 
5 /* Check that we can widen accesses to bitfields.  */
6 
7 struct bar {
8   int a : 3;
9   unsigned char b : 4;
10   unsigned char c : 1;
11   char d;
12   char e;
13   char f;
14   char g;
15 };
16 
17 __attribute__ ((noinline)) void
foozero(struct bar * p)18 foozero (struct bar *p)
19 {
20   p->b = 0;
21   p->a = 0;
22   p->c = 0;
23   p->d = 0;
24   p->e = 0;
25   p->f = 0;
26   p->g = 0;
27 }
28 
29 __attribute__ ((noinline)) void
foo1(struct bar * p)30 foo1 (struct bar *p)
31 {
32   p->b = 3;
33   p->a = 2;
34   p->c = 1;
35   p->d = 4;
36   p->e = 5;
37 }
38 
39 int
main(void)40 main (void)
41 {
42   struct bar p;
43   foozero (&p);
44   foo1 (&p);
45   if (p.a != 2 || p.b != 3 || p.c != 1 || p.d != 4 || p.e != 5
46       || p.f != 0 || p.g != 0)
47     __builtin_abort ();
48 
49   return 0;
50 }
51 
52 
53 /* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */
54