1/* { dg-do compile } */
2/* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim"  } */
3/* { dg-add-options bind_pic_locally } */
4
5struct S
6{
7  int a, b, c;
8};
9
10void *blah(int, void *);
11
12static void __attribute__ ((noinline)) foo (int x, int z, struct S *p);
13
14static void __attribute__ ((noinline))
15bar (int x, int z, struct S *p)
16{
17  foo (z, x, p);
18}
19
20static void __attribute__ ((noinline))
21foo (int x, int z, struct S *p)
22{
23  int i, c = p->c;
24  int b = p->b - z;
25  void *v = (void *) p;
26
27  if (z)
28    {
29      z--;
30      bar (z, x, p);
31    }
32  for (i = 0; i< c; i++)
33    v = blah(b + x + i, v);
34}
35
36void
37entry (int c)
38{
39  struct S s;
40  int i;
41
42  for (i = 0; i<c; i++)
43    {
44      s.a = c;
45      s.b = 64;
46      s.c = 32;
47      foo (4, i, &s);
48    }
49}
50/* { dg-final { scan-ipa-dump-times "Clone of bar" 1 "cp" } } */
51/* { dg-final { scan-ipa-dump-times "Clone of foo" 1 "cp" } } */
52/* { dg-final { cleanup-ipa-dump "cp" } } */
53/* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
54/* { dg-final { cleanup-tree-dump "optimized" } } */
55