1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fdump-tree-optimized-slim -fno-ipa-icf"  } */
3 /* { dg-add-options bind_pic_locally } */
4 
5 struct S
6 {
7   int a, b, c;
8 };
9 
10 void *blah(int, void *);
11 
12 static void __attribute__ ((noinline))
foo(struct S * p)13 foo (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 static void __attribute__ ((noinline))
bar(struct S * p)24 bar (struct S *p)
25 {
26   foo (p);
27 }
28 
29 static void __attribute__ ((noinline))
bar_2(struct S * p)30 bar_2 (struct S *p)
31 {
32   foo (p);
33 }
34 
35 void
entry1(int c)36 entry1 (int c)
37 {
38   struct S s;
39   int i;
40 
41   for (i = 0; i<c; i++)
42     {
43       s.a = 1;
44       s.b = 64;
45       s.c = 32;
46       bar (&s);
47     }
48   s.c = 2;
49   bar (&s);
50 }
51 
52 void
entry2(int c)53 entry2 (int c)
54 {
55   struct S s;
56   int i;
57 
58   for (i = 0; i<c; i++)
59     {
60       s.a = 6;
61       s.b = 64;
62       s.c = 32;
63       bar_2 (&s);
64     }
65   s.c = 2;
66   foo (&s);
67 }
68 
69 /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo/\[0-9\]*\\." 2 "cp" } } */
70 /* { dg-final { scan-ipa-dump-times "Creating a specialized node of bar/\[0-9\]*\\." 2 "cp" } } */
71 /* { dg-final { scan-ipa-dump "Creating a specialized node of bar_2.*for all known contexts" "cp" } } */
72 /* { dg-final { scan-ipa-dump-times "Aggregate replacements:" 10 "cp" } } */
73 /* { dg-final { scan-tree-dump-not "->c;" "optimized" } } */
74