OLD | NEW |
1 ; Tests the branch optimizations under O2 (against a lack of | 1 ; Tests the branch optimizations under O2 (against a lack of |
2 ; optimizations under Om1). | 2 ; optimizations under Om1). |
3 | 3 |
4 ; RUN: %p2i -i %s --args -O2 --verbose none \ | 4 ; RUN: %p2i --assemble --disassemble -i %s --args -O2 --verbose none \ |
5 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | |
6 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ | |
7 ; RUN: | FileCheck --check-prefix=O2 %s | 5 ; RUN: | FileCheck --check-prefix=O2 %s |
8 ; RUN: %p2i -i %s --args -Om1 --verbose none \ | 6 ; RUN: %p2i --assemble --disassemble -i %s --args -Om1 --verbose none \ |
9 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | |
10 ; RUN: | llvm-objdump -d -symbolize -x86-asm-syntax=intel - \ | |
11 ; RUN: | FileCheck --check-prefix=OM1 %s | 7 ; RUN: | FileCheck --check-prefix=OM1 %s |
12 | 8 |
13 declare void @dummy() | 9 declare void @dummy() |
14 | 10 |
15 ; An unconditional branch to the next block should be removed. | 11 ; An unconditional branch to the next block should be removed. |
16 define void @testUncondToNextBlock() { | 12 define void @testUncondToNextBlock() { |
17 entry: | 13 entry: |
18 call void @dummy() | 14 call void @dummy() |
19 br label %next | 15 br label %next |
20 next: | 16 next: |
(...skipping 19 matching lines...) Expand all Loading... |
40 %cmp = icmp sge i32 %arg, 123 | 36 %cmp = icmp sge i32 %arg, 123 |
41 br i1 %cmp, label %target, label %fallthrough | 37 br i1 %cmp, label %target, label %fallthrough |
42 fallthrough: | 38 fallthrough: |
43 call void @dummy() | 39 call void @dummy() |
44 ret void | 40 ret void |
45 target: | 41 target: |
46 call void @dummy() | 42 call void @dummy() |
47 ret void | 43 ret void |
48 } | 44 } |
49 ; O2-LABEL: testCondFallthroughToNextBlock | 45 ; O2-LABEL: testCondFallthroughToNextBlock |
50 ; O2: cmp {{.*}}, 123 | 46 ; O2: cmp {{.*}},0x7b |
51 ; O2-NEXT: jge | 47 ; O2-NEXT: jge |
52 ; O2-NOT: j | 48 ; O2-NOT: j |
53 ; O2: call | 49 ; O2: call |
54 ; O2: ret | 50 ; O2: ret |
55 ; O2: call | 51 ; O2: call |
56 ; O2: ret | 52 ; O2: ret |
57 | 53 |
58 ; OM1-LABEL: testCondFallthroughToNextBlock | 54 ; OM1-LABEL: testCondFallthroughToNextBlock |
59 ; OM1: cmp {{.*}}, 123 | 55 ; OM1: cmp {{.*}},0x7b |
60 ; OM1: jge | 56 ; OM1: jge |
61 ; OM1: cmp | 57 ; OM1: cmp |
62 ; OM1: jne | 58 ; OM1: jne |
63 ; OM1: jmp | 59 ; OM1: jmp |
64 ; OM1: call | 60 ; OM1: call |
65 ; OM1: ret | 61 ; OM1: ret |
66 ; OM1: call | 62 ; OM1: call |
67 ; OM1: ret | 63 ; OM1: ret |
68 | 64 |
69 ; For a conditional branch with the next block as the target and a | 65 ; For a conditional branch with the next block as the target and a |
70 ; different block as the fallthrough, the branch condition should be | 66 ; different block as the fallthrough, the branch condition should be |
71 ; inverted, the fallthrough block changed to the target, and the | 67 ; inverted, the fallthrough block changed to the target, and the |
72 ; branch to the next block removed. | 68 ; branch to the next block removed. |
73 define void @testCondTargetNextBlock(i32 %arg) { | 69 define void @testCondTargetNextBlock(i32 %arg) { |
74 entry: | 70 entry: |
75 %cmp = icmp sge i32 %arg, 123 | 71 %cmp = icmp sge i32 %arg, 123 |
76 br i1 %cmp, label %fallthrough, label %target | 72 br i1 %cmp, label %fallthrough, label %target |
77 fallthrough: | 73 fallthrough: |
78 call void @dummy() | 74 call void @dummy() |
79 ret void | 75 ret void |
80 target: | 76 target: |
81 call void @dummy() | 77 call void @dummy() |
82 ret void | 78 ret void |
83 } | 79 } |
84 ; O2-LABEL: testCondTargetNextBlock | 80 ; O2-LABEL: testCondTargetNextBlock |
85 ; O2: cmp {{.*}}, 123 | 81 ; O2: cmp {{.*}},0x7b |
86 ; O2-NEXT: jl | 82 ; O2-NEXT: jl |
87 ; O2-NOT: j | 83 ; O2-NOT: j |
88 ; O2: call | 84 ; O2: call |
89 ; O2: ret | 85 ; O2: ret |
90 ; O2: call | 86 ; O2: call |
91 ; O2: ret | 87 ; O2: ret |
92 | 88 |
93 ; OM1-LABEL: testCondTargetNextBlock | 89 ; OM1-LABEL: testCondTargetNextBlock |
94 ; OM1: cmp {{.*}}, 123 | 90 ; OM1: cmp {{.*}},0x7b |
95 ; OM1: jge | 91 ; OM1: jge |
96 ; OM1: cmp | 92 ; OM1: cmp |
97 ; OM1: jne | 93 ; OM1: jne |
98 ; OM1: jmp | 94 ; OM1: jmp |
99 ; OM1: call | 95 ; OM1: call |
100 ; OM1: ret | 96 ; OM1: ret |
101 ; OM1: call | 97 ; OM1: call |
102 ; OM1: ret | 98 ; OM1: ret |
OLD | NEW |