OLD | NEW |
1 ; This tests a switch statement, including multiple branches to the | 1 ; This tests a switch statement, including multiple branches to the |
2 ; same label which also results in phi instructions with multiple | 2 ; same label which also results in phi instructions with multiple |
3 ; entries for the same incoming edge. | 3 ; entries for the same incoming edge. |
4 | 4 |
5 ; RUN: %p2i -i %s -a --verbose inst | FileCheck %s | 5 ; RUN: %p2i -i %s --args -O2 --verbose none \ |
| 6 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
| 7 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
6 ; RUN: %p2i -i %s -a --verbose none | FileCheck --check-prefix=ERRORS %s | 8 ; RUN: %p2i -i %s -a --verbose none | FileCheck --check-prefix=ERRORS %s |
7 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s | 9 ; RUN: %p2i -i %s --insts | %szdiff %s | FileCheck --check-prefix=DUMP %s |
8 | 10 |
9 define i32 @testSwitch(i32 %a) { | 11 define i32 @testSwitch(i32 %a) { |
10 entry: | 12 entry: |
11 switch i32 %a, label %sw.default [ | 13 switch i32 %a, label %sw.default [ |
12 i32 1, label %sw.epilog | 14 i32 1, label %sw.epilog |
13 i32 2, label %sw.epilog | 15 i32 2, label %sw.epilog |
14 i32 3, label %sw.epilog | 16 i32 3, label %sw.epilog |
15 i32 7, label %sw.bb1 | 17 i32 7, label %sw.bb1 |
(...skipping 28 matching lines...) Expand all Loading... |
44 switch i32 10, label %sw.default [ | 46 switch i32 10, label %sw.default [ |
45 i32 1, label %sw.default | 47 i32 1, label %sw.default |
46 ] | 48 ] |
47 | 49 |
48 sw.default: | 50 sw.default: |
49 ret i32 20 | 51 ret i32 20 |
50 } | 52 } |
51 ; CHECK-LABEL: testSwitchImm | 53 ; CHECK-LABEL: testSwitchImm |
52 ; CHECK-NOT: cmp {{[0-9]*}}, | 54 ; CHECK-NOT: cmp {{[0-9]*}}, |
53 | 55 |
| 56 ; Test for correct 64-bit lowering. |
| 57 define internal i32 @testSwitch64(i64 %a) { |
| 58 entry: |
| 59 switch i64 %a, label %sw.default [ |
| 60 i64 123, label %return |
| 61 i64 234, label %sw.bb1 |
| 62 i64 345, label %sw.bb2 |
| 63 i64 78187493520, label %sw.bb3 |
| 64 ] |
| 65 |
| 66 sw.bb1: ; preds = %entry |
| 67 br label %return |
| 68 |
| 69 sw.bb2: ; preds = %entry |
| 70 br label %return |
| 71 |
| 72 sw.bb3: ; preds = %entry |
| 73 br label %return |
| 74 |
| 75 sw.default: ; preds = %entry |
| 76 br label %return |
| 77 |
| 78 return: ; preds = %sw.default, %sw.bb3
, %sw.bb2, %sw.bb1, %entry |
| 79 %retval.0 = phi i32 [ 5, %sw.default ], [ 4, %sw.bb3 ], [ 3, %sw.bb2 ], [ 2, %
sw.bb1 ], [ 1, %entry ] |
| 80 ret i32 %retval.0 |
| 81 } |
| 82 ; CHECK-LABEL: testSwitch64 |
| 83 ; CHECK: cmp {{.*}}, 123 |
| 84 ; CHECK-NEXT: jne |
| 85 ; CHECK-NEXT: cmp {{.*}}, 0 |
| 86 ; CHECK-NEXT: je |
| 87 ; CHECK: cmp {{.*}}, 234 |
| 88 ; CHECK-NEXT: jne |
| 89 ; CHECK-NEXT: cmp {{.*}}, 0 |
| 90 ; CHECK-NEXT: je |
| 91 ; CHECK: cmp {{.*}}, 345 |
| 92 ; CHECK-NEXT: jne |
| 93 ; CHECK-NEXT: cmp {{.*}}, 0 |
| 94 ; CHECK-NEXT: je |
| 95 ; CHECK: cmp {{.*}}, 878082192 |
| 96 ; CHECK-NEXT: jne |
| 97 ; CHECK-NEXT: cmp {{.*}}, 18 |
| 98 ; CHECK-NEXT: je |
| 99 |
| 100 ; Similar to testSwitchImm, make sure proper addressing modes are |
| 101 ; used. In reality, this is tested by running the output through the |
| 102 ; assembler. |
| 103 define i32 @testSwitchImm64() { |
| 104 entry: |
| 105 switch i64 10, label %sw.default [ |
| 106 i64 1, label %sw.default |
| 107 ] |
| 108 |
| 109 sw.default: |
| 110 ret i32 20 |
| 111 } |
| 112 ; CHECK-LABEL: testSwitchImm64 |
| 113 ; CHECK: cmp {{.*}}, 1 |
| 114 ; CHECK-NEXT: jne |
| 115 ; CHECK-NEXT: cmp {{.*}}, 0 |
| 116 ; CHECK-NEXT: je |
| 117 |
54 ; CHECK-NOT: ICE translation error | 118 ; CHECK-NOT: ICE translation error |
55 ; ERRORS-NOT: ICE translation error | 119 ; ERRORS-NOT: ICE translation error |
56 ; DUMP-NOT: SZ | 120 ; DUMP-NOT: SZ |
OLD | NEW |