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: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 4 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
5 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \ | 5 ; RUN: --target x8632 -i %s --args -O2 -allow-externally-defined-symbols \ |
6 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=O2 %s | 6 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=O2 %s |
7 | 7 |
8 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ | 8 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
9 ; RUN: --target x8632 -i %s --args -Om1 -allow-externally-defined-symbols \ | 9 ; RUN: --target x8632 -i %s --args -Om1 -allow-externally-defined-symbols \ |
10 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=OM1 %s | 10 ; RUN: | %if --need=target_X8632 --command FileCheck --check-prefix=OM1 %s |
11 | 11 |
12 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) | 12 ; TODO(jvoung): Stop skipping unimplemented parts (via --skip-unimplemented) |
13 ; once enough infrastructure is in. Also, switch to --filetype=obj | 13 ; once enough infrastructure is in. Also, switch to --filetype=obj |
14 ; when possible. | 14 ; when possible. |
15 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 15 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
16 ; RUN: --command %p2i --filetype=asm --assemble \ | 16 ; RUN: --command %p2i --filetype=asm --assemble \ |
17 ; RUN: --disassemble --target arm32 -i %s --args -O2 \ | 17 ; RUN: --disassemble --target arm32 -i %s --args -O2 \ |
18 ; RUN: -allow-externally-defined-symbols \ | 18 ; RUN: -allow-externally-defined-symbols \ |
19 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 19 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
20 ; RUN: --command FileCheck --check-prefix ARM32O2 %s | 20 ; RUN: --command FileCheck --check-prefix ARM32O2 %s |
21 | 21 |
22 ; RUN: %if --need=target_ARM32 --need=allow_dump \ | 22 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
23 ; RUN: --command %p2i --filetype=asm --assemble \ | 23 ; RUN: --command %p2i --filetype=asm --assemble \ |
24 ; RUN: --disassemble --target arm32 -i %s --args -Om1 \ | 24 ; RUN: --disassemble --target arm32 -i %s --args -Om1 \ |
25 ; RUN: -allow-externally-defined-symbols \ | 25 ; RUN: -allow-externally-defined-symbols \ |
26 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ | 26 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
27 ; RUN: --command FileCheck \ | 27 ; RUN: --command FileCheck \ |
28 ; RUN: --check-prefix ARM32OM1 %s | 28 ; RUN: --check-prefix ARM32OM1 %s |
29 | 29 |
| 30 ; TODO(jaydeep.patil): Using --skip-unimplemented for MIPS32 |
| 31 ; RUN: %if --need=target_MIPS32 --need=allow_dump \ |
| 32 ; RUN: --command %p2i --filetype=asm --assemble \ |
| 33 ; RUN: --disassemble --target mips32 -i %s --args -O2 \ |
| 34 ; RUN: --skip-unimplemented \ |
| 35 ; RUN: -allow-externally-defined-symbols \ |
| 36 ; RUN: | %if --need=target_MIPS32 --need=allow_dump \ |
| 37 ; RUN: --command FileCheck --check-prefix MIPS32O2 %s |
| 38 |
| 39 ; RUN: %if --need=target_MIPS32 --need=allow_dump \ |
| 40 ; RUN: --command %p2i --filetype=asm --assemble \ |
| 41 ; RUN: --disassemble --target mips32 -i %s --args -Om1 \ |
| 42 ; RUN: --skip-unimplemented \ |
| 43 ; RUN: -allow-externally-defined-symbols \ |
| 44 ; RUN: | %if --need=target_MIPS32 --need=allow_dump \ |
| 45 ; RUN: --command FileCheck \ |
| 46 ; RUN: --check-prefix MIPS32OM1 %s |
| 47 |
30 declare void @dummy() | 48 declare void @dummy() |
31 | 49 |
32 ; An unconditional branch to the next block should be removed. | 50 ; An unconditional branch to the next block should be removed. |
33 define internal void @testUncondToNextBlock() { | 51 define internal void @testUncondToNextBlock() { |
34 entry: | 52 entry: |
35 call void @dummy() | 53 call void @dummy() |
36 br label %next | 54 br label %next |
37 next: | 55 next: |
38 call void @dummy() | 56 call void @dummy() |
39 ret void | 57 ret void |
(...skipping 12 matching lines...) Expand all Loading... |
52 | 70 |
53 ; ARM32O2-LABEL: testUncondToNextBlock | 71 ; ARM32O2-LABEL: testUncondToNextBlock |
54 ; ARM32O2: bl {{.*}} dummy | 72 ; ARM32O2: bl {{.*}} dummy |
55 ; ARM32O2-NEXT: bl {{.*}} dummy | 73 ; ARM32O2-NEXT: bl {{.*}} dummy |
56 | 74 |
57 ; ARM32OM1-LABEL: testUncondToNextBlock | 75 ; ARM32OM1-LABEL: testUncondToNextBlock |
58 ; ARM32OM1: bl {{.*}} dummy | 76 ; ARM32OM1: bl {{.*}} dummy |
59 ; ARM32OM1-NEXT: b | 77 ; ARM32OM1-NEXT: b |
60 ; ARM32OM1-NEXT: bl {{.*}} dummy | 78 ; ARM32OM1-NEXT: bl {{.*}} dummy |
61 | 79 |
| 80 ; MIPS32O2-LABEL: testUncondToNextBlock |
| 81 ; MIPS32O2: jal {{.*}} dummy |
| 82 ; MIPS32O2-NEXT: nop |
| 83 ; MIPS32O2-LABEL: <.LtestUncondToNextBlock$next>: |
| 84 ; MIPS32O2-NEXT: jal {{.*}} dummy |
| 85 ; MIPS32O2-NEXT: nop |
| 86 |
| 87 ; MIPS32OM1-LABEL: testUncondToNextBlock |
| 88 ; MIPS32OM1: jal {{.*}} dummy |
| 89 ; MIPS32OM1-NEXT: nop |
| 90 ; MIPS32OM1-NEXT: b {{.*}} <.LtestUncondToNextBlock$next> |
| 91 ; MIPS32OM1-NEXT: nop |
| 92 ; MIPS32OM1-LABEL: <.LtestUncondToNextBlock$next>: |
| 93 ; MIPS32OM1-NEXT: jal {{.*}} dummy |
| 94 ; MIPS32OM1-NEXT: nop |
| 95 |
62 ; For a conditional branch with a fallthrough to the next block, the | 96 ; For a conditional branch with a fallthrough to the next block, the |
63 ; fallthrough branch should be removed. | 97 ; fallthrough branch should be removed. |
64 define internal void @testCondFallthroughToNextBlock(i32 %arg) { | 98 define internal void @testCondFallthroughToNextBlock(i32 %arg) { |
65 entry: | 99 entry: |
66 %cmp = icmp sge i32 %arg, 123 | 100 %cmp = icmp sge i32 %arg, 123 |
67 br i1 %cmp, label %target, label %fallthrough | 101 br i1 %cmp, label %target, label %fallthrough |
68 fallthrough: | 102 fallthrough: |
69 call void @dummy() | 103 call void @dummy() |
70 ret void | 104 ret void |
71 target: | 105 target: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 ; ARM32OM1: cmp {{.*}}, #123 | 139 ; ARM32OM1: cmp {{.*}}, #123 |
106 ; ARM32OM1: movge {{.*}}, #1 | 140 ; ARM32OM1: movge {{.*}}, #1 |
107 ; ARM32OM1: tst {{.*}}, #1 | 141 ; ARM32OM1: tst {{.*}}, #1 |
108 ; ARM32OM1: bne | 142 ; ARM32OM1: bne |
109 ; ARM32OM1: b | 143 ; ARM32OM1: b |
110 ; ARM32OM1: bl | 144 ; ARM32OM1: bl |
111 ; ARM32OM1: bx lr | 145 ; ARM32OM1: bx lr |
112 ; ARM32OM1: bl | 146 ; ARM32OM1: bl |
113 ; ARM32OM1: bx lr | 147 ; ARM32OM1: bx lr |
114 | 148 |
| 149 ; MIPS32O2-LABEL: testCondFallthroughToNextBlock |
| 150 ; MIPS32O2: li {{.*}},123 |
| 151 ; MIPS32O2: slt {{.*}},{{.*}},{{.*}} |
| 152 ; MIPS32O2: beqz |
| 153 ; MIPS32O2: nop |
| 154 ; MIPS32O2: .LtestCondFallthroughToNextBlock$fallthrough |
| 155 ; MIPS32O2: jal {{.*}} dummy |
| 156 ; MIPS32O2: nop |
| 157 ; MIPS32O2: jr |
| 158 ; MIPS32O2: nop |
| 159 ; MIPS32O2: .LtestCondFallthroughToNextBlock$target |
| 160 ; MIPS32O2: jal {{.*}} dummy |
| 161 ; MIPS32O2: nop |
| 162 ; MIPS32O2: jr |
| 163 ; MIPS32O2: nop |
| 164 |
| 165 ; MIPS32OM1-LABEL: testCondFallthroughToNextBlock |
| 166 ; MIPS32OM1: li {{.*}},123 |
| 167 ; MIPS32OM1: slt {{.*}},{{.*}},{{.*}} |
| 168 ; MIPS32OM1: xori {{.*}},{{.*}},{{.*}} |
| 169 ; MIPS32OM1: beqz |
| 170 ; MIPS32OM1: nop |
| 171 ; MIPS32OM1: b |
| 172 ; MIPS32OM1: nop |
| 173 ; MIPS32OM1: .LtestCondFallthroughToNextBlock$fallthrough |
| 174 ; MIPS32OM1: jal {{.*}} dummy |
| 175 ; MIPS32OM1: nop |
| 176 ; MIPS32OM1: jr |
| 177 ; MIPS32OM1: nop |
| 178 ; MIPS32OM1: .LtestCondFallthroughToNextBlock$target |
| 179 ; MIPS32OM1: jal {{.*}} dummy |
| 180 ; MIPS32OM1: nop |
| 181 ; MIPS32OM1: jr |
| 182 ; MIPS32OM1: nop |
| 183 |
115 ; For a conditional branch with the next block as the target and a | 184 ; For a conditional branch with the next block as the target and a |
116 ; different block as the fallthrough, the branch condition should be | 185 ; different block as the fallthrough, the branch condition should be |
117 ; inverted, the fallthrough block changed to the target, and the | 186 ; inverted, the fallthrough block changed to the target, and the |
118 ; branch to the next block removed. | 187 ; branch to the next block removed. |
119 define internal void @testCondTargetNextBlock(i32 %arg) { | 188 define internal void @testCondTargetNextBlock(i32 %arg) { |
120 entry: | 189 entry: |
121 %cmp = icmp sge i32 %arg, 123 | 190 %cmp = icmp sge i32 %arg, 123 |
122 br i1 %cmp, label %fallthrough, label %target | 191 br i1 %cmp, label %fallthrough, label %target |
123 fallthrough: | 192 fallthrough: |
124 call void @dummy() | 193 call void @dummy() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ; ARM32OM1: cmp {{.*}}, #123 | 230 ; ARM32OM1: cmp {{.*}}, #123 |
162 ; ARM32OM1: movge {{.*}}, #1 | 231 ; ARM32OM1: movge {{.*}}, #1 |
163 ; ARM32OM1: tst {{.*}}, #1 | 232 ; ARM32OM1: tst {{.*}}, #1 |
164 ; ARM32OM1: bne | 233 ; ARM32OM1: bne |
165 ; ARM32OM1: b | 234 ; ARM32OM1: b |
166 ; ARM32OM1: bl | 235 ; ARM32OM1: bl |
167 ; ARM32OM1: bx lr | 236 ; ARM32OM1: bx lr |
168 ; ARM32OM1: bl | 237 ; ARM32OM1: bl |
169 ; ARM32OM1: bx lr | 238 ; ARM32OM1: bx lr |
170 | 239 |
| 240 ; MIPS32O2-LABEL: testCondTargetNextBlock |
| 241 ; MIPS32O2: li {{.*}},123 |
| 242 ; MIPS32O2: slt {{.*}},{{.*}},{{.*}} |
| 243 ; MIPS32O2: bnez |
| 244 ; MIPS32O2: nop |
| 245 ; MIPS32O2: .LtestCondTargetNextBlock$fallthrough |
| 246 ; MIPS32O2: jal {{.*}} dummy |
| 247 ; MIPS32O2: nop |
| 248 ; MIPS32O2: jr |
| 249 ; MIPS32O2: nop |
| 250 ; MIPS32O2: .LtestCondTargetNextBlock$target |
| 251 ; MIPS32O2: jal {{.*}} dummy |
| 252 ; MIPS32O2: nop |
| 253 ; MIPS32O2: jr |
| 254 ; MIPS32O2: nop |
| 255 |
| 256 ; MIPS32OM1-LABEL: testCondTargetNextBlock |
| 257 ; MIPS32OM1: li {{.*}},123 |
| 258 ; MIPS32OM1: slt {{.*}},{{.*}},{{.*}} |
| 259 ; MIPS32OM1: xori {{.*}},{{.*}},{{.*}} |
| 260 ; MIPS32OM1: beqz |
| 261 ; MIPS32OM1: nop |
| 262 ; MIPS32OM1: b |
| 263 ; MIPS32OM1: nop |
| 264 ; MIPS32OM1: .LtestCondTargetNextBlock$fallthrough |
| 265 ; MIPS32OM1: jal {{.*}} dummy |
| 266 ; MIPS32OM1: nop |
| 267 ; MIPS32OM1: jr |
| 268 ; MIPS32OM1: nop |
| 269 ; MIPS32OM1: .LtestCondTargetNextBlock$target |
| 270 ; MIPS32OM1: jal {{.*}} dummy |
| 271 ; MIPS32OM1: nop |
| 272 ; MIPS32OM1: jr |
| 273 ; MIPS32OM1: nop |
| 274 |
171 ; Unconditional branches to the block after a contracted block should be | 275 ; Unconditional branches to the block after a contracted block should be |
172 ; removed. | 276 ; removed. |
173 define internal void @testUncondToBlockAfterContract() { | 277 define internal void @testUncondToBlockAfterContract() { |
174 entry: | 278 entry: |
175 call void @dummy() | 279 call void @dummy() |
176 br label %target | 280 br label %target |
177 contract: | 281 contract: |
178 br label %target | 282 br label %target |
179 target: | 283 target: |
180 call void @dummy() | 284 call void @dummy() |
(...skipping 13 matching lines...) Expand all Loading... |
194 ; OM1: call | 298 ; OM1: call |
195 | 299 |
196 ; ARM32O2-LABEL: testUncondToBlockAfterContract | 300 ; ARM32O2-LABEL: testUncondToBlockAfterContract |
197 ; ARM32O2: bl {{.*}} dummy | 301 ; ARM32O2: bl {{.*}} dummy |
198 ; ARM32O2-NEXT: bl {{.*}} dummy | 302 ; ARM32O2-NEXT: bl {{.*}} dummy |
199 | 303 |
200 ; ARM32OM1-LABEL: testUncondToBlockAfterContract | 304 ; ARM32OM1-LABEL: testUncondToBlockAfterContract |
201 ; ARM32OM1: bl {{.*}} dummy | 305 ; ARM32OM1: bl {{.*}} dummy |
202 ; ARM32OM1-NEXT: b | 306 ; ARM32OM1-NEXT: b |
203 ; ARM32OM1-NEXT: bl {{.*}} dummy | 307 ; ARM32OM1-NEXT: bl {{.*}} dummy |
| 308 |
| 309 ; MIPS32O2-LABEL: testUncondToBlockAfterContract |
| 310 ; MIPS32O2: jal {{.*}} dummy |
| 311 ; MIPS32O2: .LtestUncondToBlockAfterContract$target |
| 312 |
| 313 ; MIPS32OM1-LABEL: testUncondToBlockAfterContract |
| 314 ; MIPS32OM1: jal {{.*}} dummy |
| 315 ; MIPS32OM1: b |
| 316 ; MIPS32OM1: .LtestUncondToBlockAfterContract$target |
OLD | NEW |