OSDN Git Service

Scan "lea\[lq\]?\[ \t\]" instead of "lea\[ \t\]".
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / pr37275.c
1 /* PR middle-end/37275 */
2 /* { dg-do compile { target ilp32 } } */
3 /* { dg-options "-g -dA -O2 -march=i686 -fstack-protector" } */
4
5 typedef __SIZE_TYPE__ size_t;
6 extern void *memcpy (void *, const void *, size_t);
7 extern void *malloc (size_t);
8
9 typedef int A;
10
11 struct B
12 {
13   int x;
14 };
15
16 struct C
17 {
18   struct F *c1;
19   void *c2;
20 };
21
22 enum D
23 {
24   D0,
25   D1
26 };
27
28 struct E
29 {
30   struct E *e1;
31   struct E *e2;
32   struct B e3;
33   void (*fn) (void *);
34   void *fn_data;
35   enum D e4;
36   _Bool e5;
37   _Bool e6;
38 };
39
40 struct F
41 {
42   unsigned f1;
43   A f2;
44   int f3;
45 };
46
47 struct G
48 {
49   void (*fn) (void *data);
50   void *data;
51   struct C g1;
52   struct E *t;
53 };
54
55 extern void fn1 (A * m);
56 static inline void
57 fn2 (A *x)
58 {
59   if (!__sync_bool_compare_and_swap (x, 0, 1))
60     fn1 (x);
61 }
62
63 extern __thread struct G thr __attribute__ ((visibility ("hidden")));
64 static inline struct G *
65 fn3 (void)
66 {
67   return &thr;
68 }
69
70 extern struct B *fn4 (void);
71 extern struct B a;
72
73 static inline struct B *
74 fn5 (_Bool x)
75 {
76   struct E *t = fn3 ()->t;
77   if (t)
78     return &t->e3;
79   else if (x)
80     return fn4 ();
81   else
82     return &a;
83 }
84
85 void
86 fn6 (struct E *t, struct E *e1_t,
87                 struct B *prev_e3)
88 {
89   t->e1 = e1_t;
90   t->e3 = *prev_e3;
91   t->e4 = D0;
92   t->e5 = 0;
93   t->e6 = 0;
94   t->e2 = ((void *) 0);
95 }
96
97 void
98 test (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *), long x, long y, _Bool z)
99 {
100   struct G *thr = fn3 ();
101   struct F *c1 = thr->g1.c1;
102   if (!z || c1 == 0 || (unsigned) c1->f3 > 64 * c1->f1)
103     {
104       struct E t;
105
106       fn6 (&t, thr->t, fn5 (0));
107       if (thr->t)
108         t.e6 = thr->t->e6;
109       thr->t = &t;
110       if (__builtin_expect (cpyfn != ((void *) 0), 0))
111         {
112           char buf[x + y - 1];
113           char *arg = (char *) (((unsigned long) buf + y - 1)
114                                 & ~(unsigned long) (y - 1));
115           cpyfn (arg, data);
116           fn (arg);
117         }
118     }
119   else
120     {
121       struct E *t;
122       struct E *e1 = thr->t;
123       char *arg;
124
125       t = malloc (sizeof (*t) + x + y - 1);
126       arg = (char *) (((unsigned long) (t + 1) + y - 1)
127                       & ~(unsigned long) (y - 1));
128       fn6 (t, e1, fn5 (0));
129       thr->t = t;
130       if (cpyfn)
131         cpyfn (arg, data);
132       else
133         memcpy (arg, data, x);
134       thr->t = e1;
135       fn2 (&c1->f2);
136     }
137 }