Debian Codegraph @

gcc/testsuite/gcc.dg/ipa/ipcp-agg-11.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details -fno-early-inlining" } */
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 #define foo_body(p)\
13 { \
14 int i, c = (p)->c; \
15 int b = (p)->b; \
16 void *v = (void *) (p); \
17 \
18 for (i= 0; i< c; i++) \
19 v = blah(b + i, v); \
20 }
21
22 static void __attribute__ ((noinline))
23 foo_v (struct S s)
24 {
25 foo_body (&s);
26 }
27
28 static void __attribute__ ((noinline))
29 foo_r (struct S *p)
30 {
31 foo_body (p);
32 }
33
34 static void
35 goo_v (int a, int *p)
36 {
37 struct S s;
38 s.a = 101;
39 s.b = a % 7;
40 s.c = *p + 6;
41 foo_v (s);
42 }
43
44 static void
45 goo_r (int a, struct S n)
46 {
47 struct S s;
48 s.a = 1;
49 s.b = a + 5;
50 s.c = -n.b;
51 foo_r (&s);
52 }
53
54 void
55 entry ()
56 {
57 int a;
58 int v;
59 struct S s;
60
61 a = 9;
62 v = 3;
63 goo_v (a, &v);
64
65 a = 100;
66 s.b = 18;
67 goo_r (a, s);
68 }
69
70 /* { dg-final { scan-ipa-dump "offset: 0, type: int, CONST: 1" "cp" } } */
71 /* { dg-final { scan-ipa-dump "offset: 32, type: int, PASS THROUGH: 0, op plus_expr 5" "cp" } } */
72 /* { dg-final { scan-ipa-dump "offset: 64, type: int, LOAD AGG: 1 \\\[offset: 32, by value], op negate_expr" "cp" } } */
73 /* { dg-final { scan-ipa-dump "offset: 0, type: int, CONST: 101" "cp" } } */
74 /* { dg-final { scan-ipa-dump "offset: 32, type: int, PASS THROUGH: 0, op trunc_mod_expr 7" "cp" } } */
75 /* { dg-final { scan-ipa-dump "offset: 64, type: int, LOAD AGG: 1 \\\[offset: 0, by reference], op plus_expr 6" "cp" } } */
76 /* { dg-final { scan-ipa-dump "Aggregate replacements: 0\\\[0]=1\\(by_ref\\), 0\\\[4]=105\\(by_ref\\), 0\\\[8]=-18\\(by_ref\\)" "cp" } } */
77 /* { dg-final { scan-ipa-dump "Aggregate replacements: 0\\\[0]=101, 0\\\[4]=2, 0\\\[8]=9" "cp" } } */