Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

98 lines
2.2 KiB
LLVM

; RUN: llc -O3 -aarch64-min-jump-table-entries=4 -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 void @fn(i4) {
switch i4 %0, label %default [
i4 0, label %case_0
i4 1, label %case_1
i4 2, label %case_2
i4 3, label %case_3
i4 4, label %case_4
i4 5, label %case_5
]
; CHECK-LABEL: fn:
; CHECK-NOT: sub
; CHECK-NOT: cmp
; CHECK-NOT: b.hi
; CHECK: ldrb {{w[0-9]+}}, [{{x[0-9]+}}, {{x[0-9]+}}]
; CHECK: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}, lsl #2
; CHECK: br {{x[0-9]+}}
default:
unreachable
case_0:
tail call void @handle_case_00(i4 %0) #2
br label %return_label
case_1:
tail call void @handle_case_01(i4 %0) #2
br label %return_label
case_2:
tail call void @handle_case_02(i4 %0) #2
br label %return_label
case_3:
tail call void @handle_case_03(i4 %0) #2
br label %return_label
case_4:
tail call void @handle_case_04(i4 %0) #2
br label %return_label
case_5:
tail call void @handle_case_05(i4 %0) #2
br label %return_label
return_label:
ret void
}
declare void @handle_case_00(i4)
declare void @handle_case_01(i4)
declare void @handle_case_02(i4)
declare void @handle_case_03(i4)
declare void @handle_case_04(i4)
declare void @handle_case_05(i4)
define i32 @reachable_fallthrough(i32 %x) {
entry:
switch i32 %x, label %def [
i32 1, label %bb1
i32 8, label %bb2
i32 16, label %bb3
i32 32, label %bb4
i32 -64, label %bb5
]
; The switch is lowered with a jump table for cases 1--32 and case 64 handled
; separately. Even though the default of the switch is unreachable, the
; fall-through for the jump table *is* reachable so the range check must be
; emitted.
;
; CHECK-LABEL: reachable_fallthrough
; CHECK: sub [[REG:w[0-9]+]], w0, #1
; CHECK: cmp [[REG]], #31
; CHECK: b.hi
def: unreachable
bb1: br label %return
bb2: br label %return
bb3: br label %return
bb4: br label %return
bb5: br label %return
return:
%p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ]
ret i32 %p
}