Index: test/CodeGen/AArch64/switch-unreachable-default.ll =================================================================== --- /dev/null +++ test/CodeGen/AArch64/switch-unreachable-default.ll @@ -0,0 +1,93 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -O3 -o - %s | FileCheck %s + +; Test that the output in the presence of an unreachable default does not have +; a compare and branch at the top of the switch to handle the default case. + +target triple = "aarch64-unknown-linux-gnu" + +; Function Attrs: nounwind +define dso_local void @fn(i32* nocapture readonly) local_unnamed_addr #0 { +; CHECK-NOT: sub +; CHECK-NOT: cmp +; CHECK-NOT: b.hi +; CHECK-LABEL: fn: +; CHECK: // %bb.0: +; CHECK-NEXT: ldr w0, [x0] +; CHECK-NEXT: adrp x9, .LJTI0_0 +; CHECK-NEXT: add x9, x9, :lo12:.LJTI0_0 +; CHECK-NEXT: and x8, x0, #0xf +; CHECK-NEXT: ldr x8, [x9, x8, lsl #3] +; CHECK-NEXT: br x8 +; CHECK-NEXT: .LBB0_1: +; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0 +; CHECK-NEXT: b handle_case_00 +; CHECK-NEXT: .LBB0_2: +; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0 +; CHECK-NEXT: b handle_case_01 +; CHECK-NEXT: .LBB0_3: +; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0 +; CHECK-NEXT: b handle_case_02 +; CHECK-NEXT: .LBB0_4: +; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0 +; CHECK-NEXT: b handle_case_03 +; CHECK-NEXT: .LBB0_5: +; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0 +; CHECK-NEXT: b handle_case_04 +; CHECK-NEXT: .LBB0_6: +; CHECK-NEXT: // kill: def $w0 killed $w0 killed $x0 +; CHECK-NEXT: b handle_case_05 + %2 = load i32, i32* %0, align 4 + %3 = trunc i32 %2 to i4 + switch i4 %3, label %4 [ + i4 0, label %5 + i4 1, label %6 + i4 2, label %7 + i4 3, label %8 + i4 4, label %9 + i4 5, label %10 + ] + +;