1*ce1eb7afSWouter van Oortmerssen; 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*ce1eb7afSWouter van Oortmerssen; 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 3950a13cfSDan Gohman 4f0b165a7SDan Gohman; Test switch instructions. Block placement is disabled because it reorders 5f0b165a7SDan Gohman; the blocks in a way that isn't interesting here. 6950a13cfSDan Gohman 7950a13cfSDan Gohmandeclare void @foo0() 8950a13cfSDan Gohmandeclare void @foo1() 9950a13cfSDan Gohmandeclare void @foo2() 10950a13cfSDan Gohmandeclare void @foo3() 11950a13cfSDan Gohmandeclare void @foo4() 12950a13cfSDan Gohmandeclare void @foo5() 13950a13cfSDan Gohman 14e51c058eSDan Gohman; CHECK-LABEL: bar32: 151d68e80fSDan Gohman; CHECK: block {{$}} 161d68e80fSDan Gohman; CHECK: block {{$}} 171d68e80fSDan Gohman; CHECK: block {{$}} 181d68e80fSDan Gohman; CHECK: block {{$}} 191d68e80fSDan Gohman; CHECK: block {{$}} 201d68e80fSDan Gohman; CHECK: block {{$}} 211d68e80fSDan Gohman; CHECK: block {{$}} 22*ce1eb7afSWouter van Oortmerssen; 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{{$}} 237f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_1: 24755a8959SThomas Lively; CHECK: call foo0{{$}} 257f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_2: 26755a8959SThomas Lively; CHECK: call foo1{{$}} 277f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_3: 28755a8959SThomas Lively; CHECK: call foo2{{$}} 297f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_4: 30755a8959SThomas Lively; CHECK: call foo3{{$}} 317f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_5: 32755a8959SThomas Lively; CHECK: call foo4{{$}} 337f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_6: 34755a8959SThomas Lively; CHECK: call foo5{{$}} 357f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_7: 36e51c058eSDan Gohman; CHECK: return{{$}} 37950a13cfSDan Gohmandefine void @bar32(i32 %n) { 38950a13cfSDan Gohmanentry: 39950a13cfSDan Gohman switch i32 %n, label %sw.epilog [ 40950a13cfSDan Gohman i32 0, label %sw.bb 41950a13cfSDan Gohman i32 1, label %sw.bb 42950a13cfSDan Gohman i32 2, label %sw.bb 43950a13cfSDan Gohman i32 3, label %sw.bb 44950a13cfSDan Gohman i32 4, label %sw.bb 45950a13cfSDan Gohman i32 5, label %sw.bb 46950a13cfSDan Gohman i32 6, label %sw.bb 47950a13cfSDan Gohman i32 7, label %sw.bb.1 48950a13cfSDan Gohman i32 8, label %sw.bb.1 49950a13cfSDan Gohman i32 9, label %sw.bb.1 50950a13cfSDan Gohman i32 10, label %sw.bb.1 51950a13cfSDan Gohman i32 11, label %sw.bb.1 52950a13cfSDan Gohman i32 12, label %sw.bb.1 53950a13cfSDan Gohman i32 13, label %sw.bb.1 54950a13cfSDan Gohman i32 14, label %sw.bb.1 55950a13cfSDan Gohman i32 15, label %sw.bb.2 56950a13cfSDan Gohman i32 16, label %sw.bb.2 57950a13cfSDan Gohman i32 17, label %sw.bb.2 58950a13cfSDan Gohman i32 18, label %sw.bb.2 59950a13cfSDan Gohman i32 19, label %sw.bb.2 60950a13cfSDan Gohman i32 20, label %sw.bb.2 61950a13cfSDan Gohman i32 21, label %sw.bb.3 62950a13cfSDan Gohman i32 22, label %sw.bb.4 63950a13cfSDan Gohman i32 23, label %sw.bb.5 64950a13cfSDan Gohman ] 65950a13cfSDan Gohman 66950a13cfSDan Gohmansw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry 67950a13cfSDan Gohman tail call void @foo0() 68950a13cfSDan Gohman br label %sw.epilog 69950a13cfSDan Gohman 70950a13cfSDan Gohmansw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry 71950a13cfSDan Gohman tail call void @foo1() 72950a13cfSDan Gohman br label %sw.epilog 73950a13cfSDan Gohman 74950a13cfSDan Gohmansw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry 75950a13cfSDan Gohman tail call void @foo2() 76950a13cfSDan Gohman br label %sw.epilog 77950a13cfSDan Gohman 78950a13cfSDan Gohmansw.bb.3: ; preds = %entry 79950a13cfSDan Gohman tail call void @foo3() 80950a13cfSDan Gohman br label %sw.epilog 81950a13cfSDan Gohman 82950a13cfSDan Gohmansw.bb.4: ; preds = %entry 83950a13cfSDan Gohman tail call void @foo4() 84950a13cfSDan Gohman br label %sw.epilog 85950a13cfSDan Gohman 86950a13cfSDan Gohmansw.bb.5: ; preds = %entry 87950a13cfSDan Gohman tail call void @foo5() 88950a13cfSDan Gohman br label %sw.epilog 89950a13cfSDan Gohman 90950a13cfSDan Gohmansw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb 91950a13cfSDan Gohman ret void 92950a13cfSDan Gohman} 93950a13cfSDan Gohman 94e51c058eSDan Gohman; CHECK-LABEL: bar64: 951d68e80fSDan Gohman; CHECK: block {{$}} 968df30d98SThomas Lively; CHECK: i64.const 978df30d98SThomas Lively; CHECK: i64.gt_u 988df30d98SThomas Lively; CHECK: br_if 0 991d68e80fSDan Gohman; CHECK: block {{$}} 1001d68e80fSDan Gohman; CHECK: block {{$}} 1011d68e80fSDan Gohman; CHECK: block {{$}} 1021d68e80fSDan Gohman; CHECK: block {{$}} 1031d68e80fSDan Gohman; CHECK: block {{$}} 1041d68e80fSDan Gohman; CHECK: block {{$}} 1058df30d98SThomas Lively; CHECK: i32.wrap_i64 106*ce1eb7afSWouter van Oortmerssen; 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{{$}} 1077f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_2: 1088df30d98SThomas Lively; CHECK: call foo0{{$}} 1097f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_3: 1108df30d98SThomas Lively; CHECK: call foo1{{$}} 1117f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_4: 1128df30d98SThomas Lively; CHECK: call foo2{{$}} 1137f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_5: 1148df30d98SThomas Lively; CHECK: call foo3{{$}} 1157f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_6: 1168df30d98SThomas Lively; CHECK: call foo4{{$}} 1177f50c15bSThomas Lively; CHECK: .LBB{{[0-9]+}}_7: 1188df30d98SThomas Lively; CHECK: call foo5{{$}} 1198df30d98SThomas Lively; CHECK: .LBB{{[0-9]+}}_8: 120e51c058eSDan Gohman; CHECK: return{{$}} 121950a13cfSDan Gohmandefine void @bar64(i64 %n) { 122950a13cfSDan Gohmanentry: 123950a13cfSDan Gohman switch i64 %n, label %sw.epilog [ 124950a13cfSDan Gohman i64 0, label %sw.bb 125950a13cfSDan Gohman i64 1, label %sw.bb 126950a13cfSDan Gohman i64 2, label %sw.bb 127950a13cfSDan Gohman i64 3, label %sw.bb 128950a13cfSDan Gohman i64 4, label %sw.bb 129950a13cfSDan Gohman i64 5, label %sw.bb 130950a13cfSDan Gohman i64 6, label %sw.bb 131950a13cfSDan Gohman i64 7, label %sw.bb.1 132950a13cfSDan Gohman i64 8, label %sw.bb.1 133950a13cfSDan Gohman i64 9, label %sw.bb.1 134950a13cfSDan Gohman i64 10, label %sw.bb.1 135950a13cfSDan Gohman i64 11, label %sw.bb.1 136950a13cfSDan Gohman i64 12, label %sw.bb.1 137950a13cfSDan Gohman i64 13, label %sw.bb.1 138950a13cfSDan Gohman i64 14, label %sw.bb.1 139950a13cfSDan Gohman i64 15, label %sw.bb.2 140950a13cfSDan Gohman i64 16, label %sw.bb.2 141950a13cfSDan Gohman i64 17, label %sw.bb.2 142950a13cfSDan Gohman i64 18, label %sw.bb.2 143950a13cfSDan Gohman i64 19, label %sw.bb.2 144950a13cfSDan Gohman i64 20, label %sw.bb.2 145950a13cfSDan Gohman i64 21, label %sw.bb.3 146950a13cfSDan Gohman i64 22, label %sw.bb.4 147950a13cfSDan Gohman i64 23, label %sw.bb.5 148950a13cfSDan Gohman ] 149950a13cfSDan Gohman 150950a13cfSDan Gohmansw.bb: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry 151950a13cfSDan Gohman tail call void @foo0() 152950a13cfSDan Gohman br label %sw.epilog 153950a13cfSDan Gohman 154950a13cfSDan Gohmansw.bb.1: ; preds = %entry, %entry, %entry, %entry, %entry, %entry, %entry, %entry 155950a13cfSDan Gohman tail call void @foo1() 156950a13cfSDan Gohman br label %sw.epilog 157950a13cfSDan Gohman 158950a13cfSDan Gohmansw.bb.2: ; preds = %entry, %entry, %entry, %entry, %entry, %entry 159950a13cfSDan Gohman tail call void @foo2() 160950a13cfSDan Gohman br label %sw.epilog 161950a13cfSDan Gohman 162950a13cfSDan Gohmansw.bb.3: ; preds = %entry 163950a13cfSDan Gohman tail call void @foo3() 164950a13cfSDan Gohman br label %sw.epilog 165950a13cfSDan Gohman 166950a13cfSDan Gohmansw.bb.4: ; preds = %entry 167950a13cfSDan Gohman tail call void @foo4() 168950a13cfSDan Gohman br label %sw.epilog 169950a13cfSDan Gohman 170950a13cfSDan Gohmansw.bb.5: ; preds = %entry 171950a13cfSDan Gohman tail call void @foo5() 172950a13cfSDan Gohman br label %sw.epilog 173950a13cfSDan Gohman 174950a13cfSDan Gohmansw.epilog: ; preds = %entry, %sw.bb.5, %sw.bb.4, %sw.bb.3, %sw.bb.2, %sw.bb.1, %sw.bb 175950a13cfSDan Gohman ret void 176950a13cfSDan Gohman} 1778df30d98SThomas Lively 1788df30d98SThomas Lively; CHECK-LABEL: truncated: 1798df30d98SThomas Lively; CHECK: block 1808df30d98SThomas Lively; CHECK: block 1818df30d98SThomas Lively; CHECK: block 1828df30d98SThomas Lively; CHECK: i32.wrap_i64 183*ce1eb7afSWouter van Oortmerssen; CHECK-NEXT: br_table {{[^,]+}}, 0, 1, 2{{$}} 1848df30d98SThomas Lively; CHECK: .LBB{{[0-9]+}}_1 1858df30d98SThomas Lively; CHECK: end_block 1868df30d98SThomas Lively; CHECK: call foo0{{$}} 1878df30d98SThomas Lively; CHECK: return{{$}} 1888df30d98SThomas Lively; CHECK: .LBB{{[0-9]+}}_2 1898df30d98SThomas Lively; CHECK: end_block 1908df30d98SThomas Lively; CHECK: call foo1{{$}} 1918df30d98SThomas Lively; CHECK: return{{$}} 1928df30d98SThomas Lively; CHECK: .LBB{{[0-9]+}}_3 1938df30d98SThomas Lively; CHECK: end_block 1948df30d98SThomas Lively; CHECK: call foo2{{$}} 1958df30d98SThomas Lively; CHECK: return{{$}} 1968df30d98SThomas Lively; CHECK: end_function 1978df30d98SThomas Livelydefine void @truncated(i64 %n) { 1988df30d98SThomas Livelyentry: 1998df30d98SThomas Lively %m = trunc i64 %n to i32 2008df30d98SThomas Lively switch i32 %m, label %default [ 2018df30d98SThomas Lively i32 0, label %bb1 2028df30d98SThomas Lively i32 1, label %bb2 2038df30d98SThomas Lively ] 2048df30d98SThomas Lively 2058df30d98SThomas Livelybb1: 2068df30d98SThomas Lively tail call void @foo0() 2078df30d98SThomas Lively ret void 2088df30d98SThomas Lively 2098df30d98SThomas Livelybb2: 2108df30d98SThomas Lively tail call void @foo1() 2118df30d98SThomas Lively ret void 2128df30d98SThomas Lively 2138df30d98SThomas Livelydefault: 2148df30d98SThomas Lively tail call void @foo2() 2158df30d98SThomas Lively ret void 2168df30d98SThomas Lively} 217