Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / Inputs / jump_table_icp.cpp
blobbfa3994d34c9216c1a5b2bde4d49df76ea781e5c
1 #include "stub.h"
3 int total = 0;
5 int inc(int x) {
6 switch (x) {
7 case 0: total += 1 + 0; return 1;
8 case 1: total += 1 + 1; return 2;
9 case 2: total += 1 + 2; return 3;
10 case 3: total += 1 + 3; return 4;
11 case 4: total += 1 + 4; return 5;
12 case 5: total += 1 + 5; return 6;
13 default: return x + 1;
17 int inc_dup(int x) {
18 switch (x) {
19 case 0: total += 2 + 0; return 1;
20 case 1: total += 2 + 1; return 2;
21 case 2: total += 2 + 2; return 3;
22 case 3: total += 2 + 3; return 4;
23 case 4: total += 2 + 4; return 5;
24 case 5: total += 2 + 5; return 6;
25 default: return x + 1;
29 int main() {
30 int c = 0;
31 for (int i = 0; i < 10000000; ++i) {
32 int a = rand() % 7;
33 int b = rand() % 7;
34 c += inc(a) - 2*inc_dup(b);
36 return c == 0;