1 /* { dg-do run } */
2 /* { dg-skip-if "asm operand has impossible constraints" { hppa*-*-* } } */
3 /* { dg-additional-options "-fstack-protector" { target fstack_protector } } */
4 /* { dg-additional-options "-fPIC" { target fpic } } */
5
6 struct S { int *l, *u; };
7 int a[3];
8
9 __attribute__((noipa)) struct S
10 foo (void)
11 {
12 int *p = a, *q = a + 1;
13 struct S s;
14 asm volatile ("" : "+g" (p), "+g" (q) : : "memory");
15 s.l = p;
16 s.u = q;
17 a[0]++;
18 return s;
19 }
20
21 __attribute__((noipa)) void
22 bar (struct S *x)
23 {
24 asm volatile ("" : : "g" (x) : "memory");
25 if (x->l != a || x->u != a + 1)
26 __builtin_abort ();
27 a[1]++;
28 }
29
30 __attribute__((noipa)) int
31 baz (int *x, int *y)
32 {
33 int r = -1;
34 asm volatile ("" : "+g" (r) : "g" (x), "g" (y) : "memory");
35 a[2]++;
36 return r;
37 }
38
39 __attribute__((noipa)) void
40 quux (void)
41 {
42 asm volatile ("" : : : "memory");
43 }
44
45 __attribute__((noipa)) void
46 qux (void)
47 {
48 struct S v = foo ();
49 struct S w;
50 struct S x = foo ();
51 int y = 0;
52
53 w.l = x.l;
54 w.u = x.u;
55 if (baz (x.l, v.l) > 0)
56 {
57 w.l = v.l;
58 y = 1;
59 quux ();
60 }
61 if (baz (x.u, v.u) < 0)
62 {
63 w.u = v.u;
64 y = 1;
65 }
66 if (y)
67 bar (&w);
68 }
69
70 int
71 main ()
72 {
73 qux ();
74 if (a[0] != 2 || a[1] != 1 || a[2] != 2)
75 __builtin_abort ();
76 return 0;
77 }