blob: 6b9616f65ff56c09aadd59e850db1b9c26581ffc [file] [log] [blame]
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -07001; 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 Schimpf2a5324a2014-09-25 09:37:49 -07005; 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 Stichnothf7c9a142014-04-29 10:52:43 -07008
9define i32 @testSwitch(i32 %a) {
10entry:
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
21sw.default: ; preds = %entry
22 %add = add i32 %a, 27
23 br label %sw.epilog
24
25sw.bb1: ; preds = %entry, %entry
26 %phitmp = sub i32 21, %a
27 br label %sw.bb2
28
29sw.bb2: ; preds = %sw.bb1, %entry, %entry
30 %result.0 = phi i32 [ 1, %entry ], [ 1, %entry ], [ %phitmp, %sw.bb1 ]
31 br label %sw.epilog
32
33sw.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 Stichnothef8cf0e2014-08-26 22:16:29 -070038; 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.
42define i32 @testSwitchImm() {
43entry:
44 switch i32 10, label %sw.default [
45 i32 1, label %sw.default
46 ]
47
48sw.default:
49 ret i32 20
50}
51; CHECK-LABEL: testSwitchImm
52; CHECK-NOT: cmp {{[0-9]*}},
53
Jim Stichnothf7c9a142014-04-29 10:52:43 -070054; CHECK-NOT: ICE translation error
55; ERRORS-NOT: ICE translation error
56; DUMP-NOT: SZ