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