libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-prof / pr108000.c
blobc59ea799748e0f5ed06fa7c9d60298954916fc58
1 /* { dg-options "-O2" } */
3 #include <stdlib.h>
5 volatile int flag;
6 const int array_size = 10;
7 int* array;
8 int iterations = 10000000;
10 #define BAR(num) \
11 int __attribute__((noinline)) \
12 bar##num (int i, int j) \
13 { \
14 if (i == 0) \
15 return 2*num - 1; \
16 else \
17 return 2*num; \
20 BAR(1)
21 BAR(2)
22 BAR(3)
23 BAR(4)
24 BAR(5)
25 BAR(6)
26 BAR(7)
27 BAR(8)
28 BAR(9)
29 BAR(10)
30 BAR(11)
31 BAR(12)
32 BAR(13)
33 BAR(14)
34 BAR(15)
35 BAR(16)
36 BAR(17)
37 BAR(18)
38 BAR(19)
40 int __attribute__((noinline))
41 foo ()
43 switch (flag)
45 case 1:
46 return bar1 (0, 0);
47 case 2:
48 return bar2 (0, 0);
49 case 3:
50 return bar3 (0, 0);
51 case 4:
52 return bar4 (0, 0);
53 case 5:
54 return bar5 (0, 0);
55 case 6:
56 return bar6 (0, 0);
57 case 7:
58 return bar7 (0, 0);
59 case 8:
60 return bar8 (0, 0);
61 case 9:
62 return bar9 (0, 0);
63 case 10:
64 return bar10 (0, 0);
65 case 11:
66 return bar11 (0, 0);
67 case 12:
68 return bar12 (0, 0);
69 case 13:
70 return bar13 (0, 0);
71 case 14:
72 return bar14 (0, 0);
73 case 15:
74 return bar15 (0, 0);
75 case 16:
76 return bar16 (0, 0);
77 case 17:
78 return bar17 (0, 0);
79 case 18:
80 return bar18 (0, 0);
81 default:
82 return bar19(0, 0);
86 int
87 main ()
89 flag = 0;
90 array = calloc(array_size, sizeof(int));
91 for (int i = 0, j = 0; i < iterations; ++i, j = (j + 1) % 10)
92 array[j] = foo ();