1// A contrived example to test the double jump removal peephole.
2
3extern "C" unsigned long bar(unsigned long count) {
4 return count + 1;
5}
6
7unsigned long foo(unsigned long count) {
8 asm(
9 " cmpq $1,%0\n"
10 " je .L7\n"
11 " incq %0\n"
12 " jmp .L1\n"
13 ".L1: jmp .L2\n"
14 ".L2: incq %0\n"
15 " cmpq $2,%0\n"
16 " jne .L3\n"
17 " jmp .L4\n"
18 ".L3: jmp .L5\n"
19 ".L5: incq %0\n"
20 ".L4: movq %0,%%rdi\n"
21 " pop %%rbp\n"
22 " jmp .L6\n"
23 ".L7: pop %%rbp\n"
24 " incq %0\n"
25 " jmp .L6\n"
26 ".L6: jmp bar\n"
27 :
28 : "m"(count)
29 );
30 return count;
31}
32
33int main(int argc, const char* argv[]) {
34 return foo(count: 38);
35}
36

source code of bolt/test/X86/Inputs/double_jump.cpp