PR bootstrap/82916
[official-gcc.git] / gcc / testsuite / gcc.dg / store_merging_2.c
blob8cd29f4243c15730224156ca4bb8dc233f615aef
1 /* { dg-do run } */
2 /* { dg-require-effective-target store_merge } */
3 /* { dg-options "-O2 -fdump-tree-store-merging" } */
5 struct bar
7 int a;
8 unsigned char b;
9 unsigned char c;
10 short d;
11 unsigned char e;
12 unsigned char f;
13 unsigned char g;
16 __attribute__ ((noinline)) void
17 foozero (struct bar *p)
19 p->b = 0;
20 p->a = 0;
21 p->c = 0;
22 p->d = 0;
23 p->e = 0;
24 p->f = 0;
25 p->g = 0;
28 __attribute__ ((noinline)) void
29 foo1 (struct bar *p)
31 p->b = 1;
32 p->a = 2;
33 p->c = 3;
34 p->d = 4;
35 p->e = 5;
36 p->f = 0;
37 p->g = 0xff;
40 __attribute__ ((noinline)) void
41 foo2 (struct bar *p, struct bar *p2)
43 p->b = 0xff;
44 p2->b = 0xa;
45 p->a = 0xfffff;
46 p2->c = 0xc;
47 p->c = 0xff;
48 p2->d = 0xbf;
49 p->d = 0xfff;
52 int
53 main (void)
55 struct bar b1, b2;
56 foozero (&b1);
57 foozero (&b2);
59 foo1 (&b1);
60 if (b1.b != 1 || b1.a != 2 || b1.c != 3 || b1.d != 4 || b1.e != 5
61 || b1.f != 0 || b1.g != 0xff)
62 __builtin_abort ();
64 foozero (&b1);
65 /* Make sure writes to aliasing struct pointers preserve the
66 correct order. */
67 foo2 (&b1, &b1);
68 if (b1.b != 0xa || b1.a != 0xfffff || b1.c != 0xff || b1.d != 0xfff)
69 __builtin_abort ();
71 foozero (&b1);
72 foo2 (&b1, &b2);
73 if (b1.a != 0xfffff || b1.b != 0xff || b1.c != 0xff || b1.d != 0xfff
74 || b2.b != 0xa || b2.c != 0xc || b2.d != 0xbf)
75 __builtin_abort ();
77 return 0;
80 /* { dg-final { scan-tree-dump-times "Merging successful" 2 "store-merging" } } */