| OLD | NEW |
| 1 ; This tests the advanced lowering of switch statements. The advanced lowering | 1 ; This tests the advanced lowering of switch statements. The advanced lowering |
| 2 ; uses jump tables, range tests and binary search. | 2 ; uses jump tables, range tests and binary search. |
| 3 | 3 |
| 4 ; RUN: %if --need=allow_dump --command %p2i -i %s --filetype=asm --assemble \ | 4 ; RUN: %if --need=allow_dump --command %p2i -i %s --filetype=asm --assemble \ |
| 5 ; RUN: --disassemble --args --adv-switch -O2 | FileCheck %s | 5 ; RUN: --disassemble --args --adv-switch -O2 | FileCheck %s |
| 6 | 6 |
| 7 ; Dense but non-continuous ranges should be converted into a jump table. | 7 ; Dense but non-continuous ranges should be converted into a jump table. |
| 8 define internal i32 @testJumpTable(i32 %a) { | 8 define internal i32 @testJumpTable(i32 %a) { |
| 9 entry: | 9 entry: |
| 10 switch i32 %a, label %sw.default [ | 10 switch i32 %a, label %sw.default [ |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 ; CHECK-NEXT: cmp {{.*}},0x0 | 181 ; CHECK-NEXT: cmp {{.*}},0x0 |
| 182 ; CHECK-NEXT: je | 182 ; CHECK-NEXT: je |
| 183 ; CHECK: cmp {{.*}},0x159 | 183 ; CHECK: cmp {{.*}},0x159 |
| 184 ; CHECK-NEXT: jne | 184 ; CHECK-NEXT: jne |
| 185 ; CHECK-NEXT: cmp {{.*}},0x0 | 185 ; CHECK-NEXT: cmp {{.*}},0x0 |
| 186 ; CHECK-NEXT: je | 186 ; CHECK-NEXT: je |
| 187 ; CHECK: cmp {{.*}},0x34567890 | 187 ; CHECK: cmp {{.*}},0x34567890 |
| 188 ; CHECK-NEXT: jne | 188 ; CHECK-NEXT: jne |
| 189 ; CHECK-NEXT: cmp {{.*}},0x12 | 189 ; CHECK-NEXT: cmp {{.*}},0x12 |
| 190 ; CHECK-NEXT: je | 190 ; CHECK-NEXT: je |
| 191 |
| 192 ; Test for correct 64-bit jump table with UINT64_MAX as one of the values. |
| 193 define internal i32 @testJumpTable64(i64 %a) { |
| 194 entry: |
| 195 switch i64 %a, label %sw.default [ |
| 196 i64 -6, label %return |
| 197 i64 -4, label %sw.bb1 |
| 198 i64 -3, label %sw.bb2 |
| 199 i64 -1, label %sw.bb3 |
| 200 ] |
| 201 |
| 202 sw.bb1: |
| 203 br label %return |
| 204 |
| 205 sw.bb2: |
| 206 br label %return |
| 207 |
| 208 sw.bb3: |
| 209 br label %return |
| 210 |
| 211 sw.default: |
| 212 br label %return |
| 213 |
| 214 return: |
| 215 %retval.0 = phi i32 [ 5, %sw.default ], [ 4, %sw.bb3 ], [ 3, %sw.bb2 ], [ 2, %
sw.bb1 ], [ 1, %entry ] |
| 216 ret i32 %retval.0 |
| 217 } |
| 218 |
| 219 ; TODO(ascull): this should generate a jump table. For now, just make sure it |
| 220 ; doesn't crash the compiler. |
| OLD | NEW |