Jim Stichnoth | 5bc2b1d | 2014-05-22 13:38:48 -0700 | [diff] [blame] | 1 | ; This tests a switch statement, including multiple branches to the |
| 2 | ; same label which also results in phi instructions with multiple |
| 3 | ; entries for the same incoming edge. |
| 4 | |
Karl Schimpf | 2a5324a | 2014-09-25 09:37:49 -0700 | [diff] [blame] | 5 | ; RUN: %p2i -i %s -a --verbose inst | FileCheck %s |
| 6 | ; 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 |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 8 | |
| 9 | define i32 @testSwitch(i32 %a) { |
| 10 | entry: |
| 11 | switch i32 %a, label %sw.default [ |
| 12 | i32 1, label %sw.epilog |
| 13 | i32 2, label %sw.epilog |
| 14 | i32 3, label %sw.epilog |
| 15 | i32 7, label %sw.bb1 |
| 16 | i32 8, label %sw.bb1 |
| 17 | i32 15, label %sw.bb2 |
| 18 | i32 14, label %sw.bb2 |
| 19 | ] |
| 20 | |
| 21 | sw.default: ; preds = %entry |
| 22 | %add = add i32 %a, 27 |
| 23 | br label %sw.epilog |
| 24 | |
| 25 | sw.bb1: ; preds = %entry, %entry |
| 26 | %phitmp = sub i32 21, %a |
| 27 | br label %sw.bb2 |
| 28 | |
| 29 | sw.bb2: ; preds = %sw.bb1, %entry, %entry |
| 30 | %result.0 = phi i32 [ 1, %entry ], [ 1, %entry ], [ %phitmp, %sw.bb1 ] |
| 31 | br label %sw.epilog |
| 32 | |
| 33 | sw.epilog: ; preds = %sw.bb2, %sw.default, %entry, %entry, %entry |
| 34 | %result.1 = phi i32 [ %add, %sw.default ], [ %result.0, %sw.bb2 ], [ 17, %entry ], [ 17, %entry ], [ 17, %entry ] |
| 35 | ret i32 %result.1 |
| 36 | } |
| 37 | |
Jim Stichnoth | ef8cf0e | 2014-08-26 22:16:29 -0700 | [diff] [blame] | 38 | ; Check for a valid addressing mode when the switch operand is an |
| 39 | ; immediate. It's important that there is exactly one case, because |
| 40 | ; for two or more cases the source operand is legalized into a |
| 41 | ; register. |
| 42 | define i32 @testSwitchImm() { |
| 43 | entry: |
| 44 | switch i32 10, label %sw.default [ |
| 45 | i32 1, label %sw.default |
| 46 | ] |
| 47 | |
| 48 | sw.default: |
| 49 | ret i32 20 |
| 50 | } |
| 51 | ; CHECK-LABEL: testSwitchImm |
| 52 | ; CHECK-NOT: cmp {{[0-9]*}}, |
| 53 | |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 54 | ; CHECK-NOT: ICE translation error |
| 55 | ; ERRORS-NOT: ICE translation error |
| 56 | ; DUMP-NOT: SZ |