libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr106590.c
blobb7b847201487f6b1c4a94107accd0f9600f1353a
1 /* PR rtl-optimization/106590 } */
2 /* { dg-do run } */
3 /* { dg-additional-options "-mtune=skylake" { target { i?86-*-* x86_64-*-* } } } */
5 typedef struct A { short a; } A;
6 typedef A *B;
7 typedef struct C { int c, d; } C;
8 typedef C *D;
11 foo (void)
13 static A r = { .a = 1 };
14 return &r;
18 bar (void)
20 static C r = { .c = 1, .d = 23 };
21 return &r;
24 static inline int __attribute__((always_inline))
25 baz (short a)
27 int e = 1, f;
28 short g;
29 D h;
31 switch (a)
33 case 1:
34 f = 23;
35 g = 1;
36 break;
37 case 2:
38 f = 20;
39 g = 2;
40 break;
43 h = bar ();
45 if (h->d != f || h->c != g)
46 __builtin_abort ();
47 return e;
50 int
51 qux (void)
53 B i = foo ();
54 int e = 1;
56 switch (i->a)
58 case 1:
59 case 2:
60 e = baz (i->a);
61 break;
62 case 3:
63 e = 0;
64 break;
67 return e;
70 int
71 main ()
73 qux ();
74 return 0;