1; RUN: llc -O3 -aarch64-min-jump-table-entries=4 -o - %s | FileCheck %s 2 3; Test that the output in the presence of an unreachable default does not have 4; a compare and branch at the top of the switch to handle the default case. 5 6target triple = "aarch64-unknown-linux-gnu" 7 8; Function Attrs: nounwind 9define void @fn(i4) { 10 switch i4 %0, label %default [ 11 i4 0, label %case_0 12 i4 1, label %case_1 13 i4 2, label %case_2 14 i4 3, label %case_3 15 i4 4, label %case_4 16 i4 5, label %case_5 17 ] 18 19; CHECK-LABEL: fn: 20; CHECK-NOT: sub 21; CHECK-NOT: cmp 22; CHECK-NOT: b.hi 23; CHECK: ldrb {{w[0-9]+}}, [{{x[0-9]+}}, {{x[0-9]+}}] 24; CHECK: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, lsl #2 25; CHECK: br {{x[0-9]+}} 26 27default: 28 unreachable 29 30case_0: 31 tail call void @handle_case_00(i4 %0) #2 32 br label %return_label 33 34case_1: 35 tail call void @handle_case_01(i4 %0) #2 36 br label %return_label 37 38case_2: 39 tail call void @handle_case_02(i4 %0) #2 40 br label %return_label 41 42case_3: 43 tail call void @handle_case_03(i4 %0) #2 44 br label %return_label 45 46case_4: 47 tail call void @handle_case_04(i4 %0) #2 48 br label %return_label 49 50case_5: 51 tail call void @handle_case_05(i4 %0) #2 52 br label %return_label 53 54return_label: 55 ret void 56} 57 58declare void @handle_case_00(i4) 59declare void @handle_case_01(i4) 60declare void @handle_case_02(i4) 61declare void @handle_case_03(i4) 62declare void @handle_case_04(i4) 63declare void @handle_case_05(i4) 64 65 66 67define i32 @reachable_fallthrough(i32 %x) { 68entry: 69 switch i32 %x, label %def [ 70 i32 1, label %bb1 71 i32 8, label %bb2 72 i32 16, label %bb3 73 i32 32, label %bb4 74 i32 -64, label %bb5 75 ] 76 77; The switch is lowered with a jump table for cases 1--32 and case 64 handled 78; separately. Even though the default of the switch is unreachable, the 79; fall-through for the jump table *is* reachable so the range check must be 80; emitted. 81; 82; CHECK-LABEL: reachable_fallthrough 83; CHECK: sub [[REG:w[0-9]+]], w0, #1 84; CHECK: cmp [[REG]], #31 85; CHECK: b.hi 86 87def: unreachable 88bb1: br label %return 89bb2: br label %return 90bb3: br label %return 91bb4: br label %return 92bb5: br label %return 93 94return: 95 %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ] 96 ret i32 %p 97} 98