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))
13foo (struct S *p)
14{
15  int i, c = p->c;
16  int b = p->b;
17  void *v = (void *) p;
18
19  for (i= 0; i< c; i++)
20    v = blah(b + i, v);
21}
22
23
24void
25entry1 (int c)
26{
27  struct S s;
28  int i;
29
30  for (i = 0; i<c; i++)
31    {
32      s.a = 1;
33      s.b = 64;
34      s.c = 32;
35      foo (&s);
36    }
37  s.c = 2;
38  foo (&s);
39}
40
41void
42entry2 (int c)
43{
44  struct S s;
45  int i;
46
47  for (i = 0; i<c; i++)
48    {
49      s.a = 6;
50      s.b = 64;
51      s.c = 32;
52      foo (&s);
53    }
54  s.c = 2;
55  foo (&s);
56}
57
58/* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
59/* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 4 "cp" } } */
60/* { dg-final { cleanup-ipa-dump "cp" } } */
61/* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
62/* { dg-final { cleanup-tree-dump "optimized" } } */
63