Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/Inline/inline-cost-switch-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

131 lines
2.9 KiB
LLVM

; RUN: opt -S -passes=inline %s -debug-only=inline-cost -min-jump-table-entries=4 --disable-output 2>&1 | FileCheck %s -check-prefix=LOOKUPTABLE -match-full-lines
; RUN: opt -S -passes=inline %s -debug-only=inline-cost -min-jump-table-entries=5 --disable-output 2>&1 | FileCheck %s -check-prefix=SWITCH -match-full-lines
; REQUIRES: x86_64-linux, asserts
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i64 @main(i64 %a) {
%b = call i64 @small_switch_default(i64 %a)
%c = call i64 @small_switch_no_default(i64 %a)
%d = call i64 @lookup_table_default(i64 %a)
%e = call i64 @lookup_table_no_default(i64 %a)
ret i64 %b
}
; SWITCH-LABEL: Analyzing call of small_switch_default{{.*}}
; SWITCH: Cost: 0
define i64 @small_switch_default(i64 %a) {
switch i64 %a, label %default_branch [
i64 -1, label %branch_0
i64 8, label %branch_1
i64 52, label %branch_2
]
branch_0:
br label %exit
branch_1:
br label %exit
branch_2:
br label %exit
default_branch:
br label %exit
exit:
%b = phi i64 [ 5, %branch_0 ], [ 9, %branch_1 ], [ 2, %branch_2 ], [ 3, %default_branch ]
ret i64 %b
}
; SWITCH-LABEL: Analyzing call of small_switch_no_default{{.*}}
; SWITCH: Cost: -10
define i64 @small_switch_no_default(i64 %a) {
switch i64 %a, label %unreachabledefault [
i64 -1, label %branch_0
i64 8, label %branch_1
i64 52, label %branch_2
]
branch_0:
br label %exit
branch_1:
br label %exit
branch_2:
br label %exit
unreachabledefault:
unreachable
exit:
%b = phi i64 [ 5, %branch_0 ], [ 9, %branch_1 ], [ 2, %branch_2 ]
ret i64 %b
}
; LOOKUPTABLE-LABEL: Analyzing call of lookup_table_default{{.*}}
; LOOKUPTABLE: Cost: 10
; SWITCH-LABEL: Analyzing call of lookup_table_default{{.*}}
; SWITCH: Cost: 20
define i64 @lookup_table_default(i64 %a) {
switch i64 %a, label %default_branch [
i64 0, label %branch_0
i64 1, label %branch_1
i64 2, label %branch_2
i64 3, label %branch_3
]
branch_0:
br label %exit
branch_1:
br label %exit
branch_2:
br label %exit
branch_3:
br label %exit
default_branch:
br label %exit
exit:
%b = phi i64 [ 5, %branch_0 ], [ 9, %branch_1 ], [ 2, %branch_2 ], [ 7, %branch_3 ], [ 3, %default_branch ]
ret i64 %b
}
; LOOKUPTABLE-LABEL: Analyzing call of lookup_table_no_default{{.*}}
; LOOKUPTABLE: Cost: 0
; SWITCH-LABEL: Analyzing call of lookup_table_no_default{{.*}}
; SWITCH: Cost: 20
define i64 @lookup_table_no_default(i64 %a) {
switch i64 %a, label %unreachabledefault [
i64 0, label %branch_0
i64 1, label %branch_1
i64 2, label %branch_2
i64 3, label %branch_3
]
branch_0:
br label %exit
branch_1:
br label %exit
branch_2:
br label %exit
branch_3:
br label %exit
unreachabledefault:
unreachable
exit:
%b = phi i64 [ 5, %branch_0 ], [ 9, %branch_1 ], [ 2, %branch_2 ], [ 7, %branch_3 ]
ret i64 %b
}