Debian Codegraph @

gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fdump-ipa-cp-details" } */
3
4 #define N 4
5
6 typedef int (* const A[N])(int);
7
8 typedef struct S
9 {
10 int add_offset;
11 A a;
12 } S;
13
14 extern const S *gs, *hs;
15
16 static int __attribute__((noinline))
17 foo (const S f, int x)
18 {
19 gs = &f;
20 x = f.a[2](x);
21 x = f.a[2](x);
22 x = f.a[2](x);
23 return x;
24 }
25
26 static int __attribute__((noinline))
27 bar (const S f, int x)
28 {
29 hs = &f;
30 return foo (f, x);
31 }
32
33 static int
34 zero (int x)
35 {
36 return 0;
37 }
38
39 static int
40 addone (int x)
41 {
42 return x + 1;
43 }
44
45 static int
46 sq (int x)
47 {
48 return x * x;
49 }
50
51 static int
52 cube (int x)
53 {
54 return x * x * x;
55 }
56
57 static const S s = {64, {zero, addone, sq, cube}};
58
59 int
60 h (int x)
61 {
62 return bar (s, x);
63 }
64
65 /* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" } } */