1 ; RUN: llc -O3 -aarch64-min-jump-table-entries=4 -o - %s | FileCheck %s
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.
6 target triple = "aarch64-unknown-linux-gnu"
8 ; Function Attrs: nounwind
10 switch i4 %0, label %default [
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]+}}
31 tail call void @handle_case_00(i4 %0) #2
32 br label %return_label
35 tail call void @handle_case_01(i4 %0) #2
36 br label %return_label
39 tail call void @handle_case_02(i4 %0) #2
40 br label %return_label
43 tail call void @handle_case_03(i4 %0) #2
44 br label %return_label
47 tail call void @handle_case_04(i4 %0) #2
48 br label %return_label
51 tail call void @handle_case_05(i4 %0) #2
52 br label %return_label
58 declare void @handle_case_00(i4)
59 declare void @handle_case_01(i4)
60 declare void @handle_case_02(i4)
61 declare void @handle_case_03(i4)
62 declare void @handle_case_04(i4)
63 declare void @handle_case_05(i4)
67 define i32 @reachable_fallthrough(i32 %x) {
69 switch i32 %x, label %def [
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
82 ; CHECK-LABEL: reachable_fallthrough
83 ; CHECK: sub [[REG:w[0-9]+]], w0, #1
84 ; CHECK: cmp [[REG]], #31
95 %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ]