1 ; RUN: llc < %s --mtriple=wasm32-unknown-unknown -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs | FileCheck %s
2 ; RUN: llc < %s --mtriple=wasm64-unknown-unknown -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -disable-block-placement -verify-machineinstrs | FileCheck %s
4 ; Test switch instructions. Block placement is disabled because it reorders
5 ; the blocks in a way that isn't interesting here.
22 ; CHECK-NEXT: 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, 6{{$}}
23 ; CHECK: .LBB{{[0-9]+}}_1:
24 ; CHECK: call foo0{{$}}
25 ; CHECK: .LBB{{[0-9]+}}_2:
26 ; CHECK: call foo1{{$}}
27 ; CHECK: .LBB{{[0-9]+}}_3:
28 ; CHECK: call foo2{{$}}
29 ; CHECK: .LBB{{[0-9]+}}_4:
30 ; CHECK: call foo3{{$}}
31 ; CHECK: .LBB{{[0-9]+}}_5:
32 ; CHECK: call foo4{{$}}
33 ; CHECK: .LBB{{[0-9]+}}_6:
34 ; CHECK: call foo5{{$}}
35 ; CHECK: .LBB{{[0-9]+}}_7:
37 define void @bar32(i32 %n) {
39 switch i32 %n, label %sw.epilog [
50 i32 10, label %sw.bb.1
51 i32 11, label %sw.bb.1
52 i32 12, label %sw.bb.1
53 i32 13, label %sw.bb.1
54 i32 14, label %sw.bb.1
55 i32 15, label %sw.bb.2
56 i32 16, label %sw.bb.2
57 i32 17, label %sw.bb.2
58 i32 18, label %sw.bb.2
59 i32 19, label %sw.bb.2
60 i32 20, label %sw.bb.2
61 i32 21, label %sw.bb.3
62 i32 22, label %sw.bb.4
63 i32 23, label %sw.bb.5
66 sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
67 tail call void @foo0()
70 sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
71 tail call void @foo1()
74 sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
75 tail call void @foo2()
78 sw.bb.3: ; preds = %entry
79 tail call void @foo3()
82 sw.bb.4: ; preds = %entry
83 tail call void @foo4()
86 sw.bb.5: ; preds = %entry
87 tail call void @foo5()
90 sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
105 ; CHECK: i32.wrap_i64
106 ; CHECK-NEXT: 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{{$}}
107 ; CHECK: .LBB{{[0-9]+}}_2:
108 ; CHECK: call foo0{{$}}
109 ; CHECK: .LBB{{[0-9]+}}_3:
110 ; CHECK: call foo1{{$}}
111 ; CHECK: .LBB{{[0-9]+}}_4:
112 ; CHECK: call foo2{{$}}
113 ; CHECK: .LBB{{[0-9]+}}_5:
114 ; CHECK: call foo3{{$}}
115 ; CHECK: .LBB{{[0-9]+}}_6:
116 ; CHECK: call foo4{{$}}
117 ; CHECK: .LBB{{[0-9]+}}_7:
118 ; CHECK: call foo5{{$}}
119 ; CHECK: .LBB{{[0-9]+}}_8:
121 define void @bar64(i64 %n) {
123 switch i64 %n, label %sw.epilog [
131 i64 7, label %sw.bb.1
132 i64 8, label %sw.bb.1
133 i64 9, label %sw.bb.1
134 i64 10, label %sw.bb.1
135 i64 11, label %sw.bb.1
136 i64 12, label %sw.bb.1
137 i64 13, label %sw.bb.1
138 i64 14, label %sw.bb.1
139 i64 15, label %sw.bb.2
140 i64 16, label %sw.bb.2
141 i64 17, label %sw.bb.2
142 i64 18, label %sw.bb.2
143 i64 19, label %sw.bb.2
144 i64 20, label %sw.bb.2
145 i64 21, label %sw.bb.3
146 i64 22, label %sw.bb.4
147 i64 23, label %sw.bb.5
150 sw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry
151 tail call void @foo0()
154 sw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry
155 tail call void @foo1()
158 sw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry
159 tail call void @foo2()
162 sw.bb.3: ; preds = %entry
163 tail call void @foo3()
166 sw.bb.4: ; preds = %entry
167 tail call void @foo4()
170 sw.bb.5: ; preds = %entry
171 tail call void @foo5()
174 sw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb
178 ; CHECK-LABEL: truncated:
182 ; CHECK: i32.wrap_i64
183 ; CHECK-NEXT: br_table {{[^,]+}}, 0, 1, 2{{$}}
184 ; CHECK: .LBB{{[0-9]+}}_1
186 ; CHECK: call foo0{{$}}
188 ; CHECK: .LBB{{[0-9]+}}_2
190 ; CHECK: call foo1{{$}}
192 ; CHECK: .LBB{{[0-9]+}}_3
194 ; CHECK: call foo2{{$}}
196 ; CHECK: end_function
197 define void @truncated(i64 %n) {
199 %m = trunc i64 %n to i32
200 switch i32 %m, label %default [
206 tail call void @foo0()
210 tail call void @foo1()
214 tail call void @foo2()