* ipa-fnsummary.c (analyze_function_body): Accumulate time consistently
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / ipcp-2.c
blob6b6fc4e4318a842e6fbdc51e162a4785eb7f106e
1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fipa-cp -fipa-cp-clone -fdump-ipa-cp -fno-early-inlining --param ipa-cp-eval-threshold=80" } */
3 /* { dg-add-options bind_pic_locally } */
5 extern int get_stuff (int);
6 extern void do_stuff (int);
7 extern void do_stuff2 (int);
8 extern void do_other_stuff (void);
9 extern int get_element (int, int, int);
10 extern int adjust (int, int, int, int);
12 extern int count;
14 int
15 foo (int s, int p)
17 int c, r = 0;
19 for (c = 0 ; c < count; c++)
21 r += get_stuff (s);
22 /* The following is just something big that can go away. */
23 if (p != 0)
25 int a[64][64];
26 int i, j, k;
28 for (i = 0; i < 64; i++)
29 for (j = 0; j < 64; j++)
30 a[i][j] = get_element (p + c, i, j);
32 for (k = 0; k < 4; k++)
34 r = r / 2;
36 for (i = 1; i < 63; i++)
37 for (j = 62; j > 0; j--)
38 a[i][j] += adjust (a[i-1][j], a[i][j-1],
39 a[i+1][j], a[i][j+1]);
41 for (i = 4; i < 64; i += 4)
42 for (j = 4; j < 64; j += 4)
43 r += a[i][j] / 4;
47 return r;
50 int
51 bar (int p, int q)
53 if (q > 0)
54 do_stuff (q);
55 else
56 do_stuff (-q);
58 if (q % 2)
59 do_stuff2 (2 * q);
60 else
61 do_stuff2 (2 * (q + 1));
63 return foo (4, p);
66 int
67 bah (int p, int q)
69 int i, j;
71 while (q < -20)
72 q += get_stuff (-q);
74 for (i = 0; i < 36; i++)
75 for (j = 0; j < 36; j++)
76 do_stuff (get_stuff (q * i + 2));
78 bar (p, q);
81 int
82 top1 (int q)
84 do_other_stuff ();
85 return bah (0, q);
88 int
89 top2 (int q)
91 do_stuff (200);
92 do_other_stuff ();
93 return bah (16, q);
96 /* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo" 1 "cp" } } */
97 /* { dg-final { scan-ipa-dump-times "replacing param .. p with const 0" 3 "cp" } } */
98 /* { dg-final { scan-ipa-dump "replacing param .0 s with const 4" "cp" } } */