1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs | FileCheck %s
3 ; Test switch instructions. Block placement is disabled because it reorders
4 ; the blocks in a way that isn't interesting here.
6 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7 target triple = "wasm32-unknown-unknown"
24 ; CHECK: br_table {{[^,]+}}, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0{{$}}
25 ; CHECK: .LBB{{[0-9]+}}_2:
26 ; CHECK: call foo0{{$}}
27 ; CHECK: .LBB{{[0-9]+}}_3:
28 ; CHECK: call foo1{{$}}
29 ; CHECK: .LBB{{[0-9]+}}_4:
30 ; CHECK: call foo2{{$}}
31 ; CHECK: .LBB{{[0-9]+}}_5:
32 ; CHECK: call foo3{{$}}
33 ; CHECK: .LBB{{[0-9]+}}_6:
34 ; CHECK: call foo4{{$}}
35 ; CHECK: .LBB{{[0-9]+}}_7:
36 ; CHECK: call foo5{{$}}
37 ; CHECK: .LBB{{[0-9]+}}_8:
39 define void @bar32(i32 %n) {
41 switch i32 %n, label %sw.epilog [
52 i32 10, label %sw.bb.1
53 i32 11, label %sw.bb.1
54 i32 12, label %sw.bb.1
55 i32 13, label %sw.bb.1
56 i32 14, label %sw.bb.1
57 i32 15, label %sw.bb.2
58 i32 16, label %sw.bb.2
59 i32 17, label %sw.bb.2
60 i32 18, label %sw.bb.2
61 i32 19, label %sw.bb.2
62 i32 20, label %sw.bb.2
63 i32 21, label %sw.bb.3
64 i32 22, label %sw.bb.4
65 i32 23, label %sw.bb.5
68 sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
69 tail call void @foo0()
72 sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
73 tail call void @foo1()
76 sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
77 tail call void @foo2()
80 sw.bb.3: ; preds = %entry
81 tail call void @foo3()
84 sw.bb.4: ; preds = %entry
85 tail call void @foo4()
88 sw.bb.5: ; preds = %entry
89 tail call void @foo5()
92 sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
104 ; CHECK: br_table {{[^,]+}}, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 4, 5, 0{{$}}
105 ; CHECK: .LBB{{[0-9]+}}_2:
106 ; CHECK: call foo0{{$}}
107 ; CHECK: .LBB{{[0-9]+}}_3:
108 ; CHECK: call foo1{{$}}
109 ; CHECK: .LBB{{[0-9]+}}_4:
110 ; CHECK: call foo2{{$}}
111 ; CHECK: .LBB{{[0-9]+}}_5:
112 ; CHECK: call foo3{{$}}
113 ; CHECK: .LBB{{[0-9]+}}_6:
114 ; CHECK: call foo4{{$}}
115 ; CHECK: .LBB{{[0-9]+}}_7:
116 ; CHECK: call foo5{{$}}
117 ; CHECK: .LBB{{[0-9]+}}_8:
119 define void @bar64(i64 %n) {
121 switch i64 %n, label %sw.epilog [
129 i64 7, label %sw.bb.1
130 i64 8, label %sw.bb.1
131 i64 9, label %sw.bb.1
132 i64 10, label %sw.bb.1
133 i64 11, label %sw.bb.1
134 i64 12, label %sw.bb.1
135 i64 13, label %sw.bb.1
136 i64 14, label %sw.bb.1
137 i64 15, label %sw.bb.2
138 i64 16, label %sw.bb.2
139 i64 17, label %sw.bb.2
140 i64 18, label %sw.bb.2
141 i64 19, label %sw.bb.2
142 i64 20, label %sw.bb.2
143 i64 21, label %sw.bb.3
144 i64 22, label %sw.bb.4
145 i64 23, label %sw.bb.5
148 sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
149 tail call void @foo0()
152 sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
153 tail call void @foo1()
156 sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
157 tail call void @foo2()
160 sw.bb.3: ; preds = %entry
161 tail call void @foo3()
164 sw.bb.4: ; preds = %entry
165 tail call void @foo4()
168 sw.bb.5: ; preds = %entry
169 tail call void @foo5()
172 sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb