98 lines · plain
1; RUN: llc -O3 -aarch64-min-jump-table-entries=4 -o - %s | FileCheck %s2 3; Test that the output in the presence of an unreachable default does not have4; 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: nounwind9define void @fn(i4) {10 switch i4 %0, label %default [11 i4 0, label %case_012 i4 1, label %case_113 i4 2, label %case_214 i4 3, label %case_315 i4 4, label %case_416 i4 5, label %case_517 ]18 19; CHECK-LABEL: fn:20; CHECK-NOT: sub21; CHECK-NOT: cmp22; CHECK-NOT: b.hi23; CHECK: ldrb {{w[0-9]+}}, [{{x[0-9]+}}, {{x[0-9]+}}]24; CHECK: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, lsl #225; CHECK: br {{x[0-9]+}}26 27default:28 unreachable29 30case_0:31 tail call void @handle_case_00(i4 %0) #232 br label %return_label33 34case_1:35 tail call void @handle_case_01(i4 %0) #236 br label %return_label37 38case_2:39 tail call void @handle_case_02(i4 %0) #240 br label %return_label41 42case_3:43 tail call void @handle_case_03(i4 %0) #244 br label %return_label45 46case_4:47 tail call void @handle_case_04(i4 %0) #248 br label %return_label49 50case_5:51 tail call void @handle_case_05(i4 %0) #252 br label %return_label53 54return_label:55 ret void56}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 %bb171 i32 8, label %bb272 i32 16, label %bb373 i32 32, label %bb474 i32 -64, label %bb575 ]76 77; The switch is lowered with a jump table for cases 1--32 and case 64 handled78; separately. Even though the default of the switch is unreachable, the79; fall-through for the jump table *is* reachable so the range check must be80; emitted.81;82; CHECK-LABEL: reachable_fallthrough83; CHECK: sub [[REG:w[0-9]+]], w0, #184; CHECK: cmp [[REG]], #3185; CHECK: b.hi86 87def: unreachable88bb1: br label %return89bb2: br label %return90bb3: br label %return91bb4: br label %return92bb5: br label %return93 94return:95 %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ]96 ret i32 %p97}98