1 /* { dg-do compile } */
2 /* { dg-options "-O3 -fipa-cp -fipa-cp-clone -fdump-ipa-cp -fno-early-inlining --param ipa-cp-eval-threshold=200"  } */
3 /* { dg-add-options bind_pic_locally } */
4 
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);
11 
12 extern int count;
13 
14 int
foo(int s,int p)15 foo (int s, int p)
16 {
17   int c, r = 0;
18 
19   for (c = 0 ; c < count; c++)
20     {
21       r += get_stuff (s);
22       /* The following is just something big that can go away.  */
23       if (p != 0)
24 	{
25 	  int a[64][64];
26 	  int i, j, k;
27 
28 	  for (i = 0; i < 64; i++)
29 	    for (j = 0; j < 64; j++)
30 	      a[i][j] = get_element (p + c, i, j);
31 
32 	  for (k = 0; k < 4; k++)
33 	    {
34 	      r = r / 2;
35 
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]);
40 
41 	      for (i = 4; i < 64; i += 4)
42 		for (j = 4; j < 64; j += 4)
43 		  r += a[i][j] / 4;
44 	    }
45 	}
46     }
47   return r;
48 }
49 
50 int
bar(int p,int q)51 bar (int p, int q)
52 {
53   if (q > 0)
54     do_stuff (q);
55   else
56     do_stuff (-q);
57 
58   if (q % 2)
59     do_stuff2 (2 * q);
60   else
61     do_stuff2 (2 * (q + 1));
62 
63   return foo (4, p);
64 }
65 
66 int
bah(int p,int q)67 bah (int p, int q)
68 {
69   int i, j;
70 
71   while (q < -20)
72     q += get_stuff (-q);
73 
74   for (i = 0; i < 36; i++)
75     for (j = 0; j < 36; j++)
76       do_stuff (get_stuff (q * i + 2));
77 
78   bar (p, q);
79 }
80 
81 int
top1(int q)82 top1 (int q)
83 {
84   do_other_stuff ();
85   return bah (0, q);
86 }
87 
88 int
top2(int q)89 top2 (int q)
90 {
91   do_stuff (200);
92   do_other_stuff ();
93   return bah (16, q);
94 }
95 
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"  } } */
99