Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-alloca-argument-cost.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

95 lines
3.5 KiB
LLVM

; RUN: opt -mtriple=amdgcn--amdhsa -S -passes=inline -inline-threshold=0 -debug-only=inline-cost %s 2>&1 | FileCheck %s
; REQUIRES: asserts
; Verify we are properly adding cost of the -amdgpu-inline-arg-alloca-cost to the threshold.
define void @local_access_only(ptr addrspace(5) %p, i32 %idx) {
%arrayidx = getelementptr inbounds [64 x float], ptr addrspace(5) %p, i32 0, i32 %idx
%value = load float, ptr addrspace(5) %arrayidx
store float %value , ptr addrspace(5) %arrayidx, align 4
ret void
}
; Below the cutoff, the alloca cost is 0, and only the cost of the instructions saved by sroa is counted
; CHECK: Analyzing call of local_access_only... (caller:test_inliner_sroa_single_below_cutoff)
; CHECK: NumAllocaArgs: 1
; CHECK: SROACostSavings: 10
; CHECK: SROACostSavingsLost: 0
; CHECK: Threshold: 66000
define amdgpu_kernel void @test_inliner_sroa_single_below_cutoff(ptr addrspace(1) %a, i32 %n) {
entry:
%pvt_arr = alloca [64 x float], align 4, addrspace(5)
call void @local_access_only(ptr addrspace(5) %pvt_arr, i32 4)
ret void
}
; Above the cutoff, attribute a cost to the alloca
; CHECK: Analyzing call of local_access_only... (caller:test_inliner_sroa_single_above_cutoff)
; CHECK: NumAllocaArgs: 1
; CHECK: SROACostSavings: 66010
; CHECK: SROACostSavingsLost: 0
; CHECK: Threshold: 66000
define amdgpu_kernel void @test_inliner_sroa_single_above_cutoff(ptr addrspace(1) %a, i32 %n) {
entry:
%pvt_arr = alloca [65 x float], align 4, addrspace(5)
call void @local_access_only(ptr addrspace(5) %pvt_arr, i32 4)
ret void
}
define void @use_first_externally(ptr addrspace(5) %p1, ptr addrspace(5) %p2) {
call void @external(ptr addrspace(5) %p1)
%arrayidx = getelementptr inbounds [64 x float], ptr addrspace(5) %p2, i32 0, i32 7
%value = load float, ptr addrspace(5) %arrayidx
store float %value , ptr addrspace(5) %arrayidx, align 4
ret void
}
define void @use_both_externally(ptr addrspace(5) %p1, ptr addrspace(5) %p2) {
call void @external(ptr addrspace(5) %p1)
call void @external(ptr addrspace(5) %p2)
ret void
}
; One array cannot get handled by SROA
; CHECK: Analyzing call of use_first_externally... (caller:test_inliner_sroa_double)
; CHECK: NumAllocaArgs: 2
; CHECK: SROACostSavings: 32502
; CHECK: SROACostSavingsLost: 33507
; CHECK: Threshold: 66000
define amdgpu_kernel void @test_inliner_sroa_double() {
entry:
%pvt_arr1 = alloca [33 x float], align 4, addrspace(5)
%pvt_arr2 = alloca [32 x float], align 4, addrspace(5)
call void @use_first_externally(ptr addrspace(5) %pvt_arr1, ptr addrspace(5) %pvt_arr2)
ret void
}
; The two arrays cannot get handled by SROA
; CHECK: Analyzing call of use_both_externally... (caller:test_inliner_no_sroa)
; CHECK: NumAllocaArgs: 2
; CHECK: SROACostSavings: 0
; CHECK: SROACostSavingsLost: 65999
; CHECK: Threshold: 66000
define amdgpu_kernel void @test_inliner_no_sroa() {
entry:
%pvt_arr1 = alloca [33 x float], align 4, addrspace(5)
%pvt_arr2 = alloca [32 x float], align 4, addrspace(5)
call void @use_both_externally(ptr addrspace(5) %pvt_arr1, ptr addrspace(5) %pvt_arr2)
ret void
}
; No private arrays
; CHECK: Analyzing call of use_both_externally... (caller:test_inliner_no_alloc)
; CHECK: NumAllocaArgs: 0
; CHECK: SROACostSavings: 0
; CHECK: SROACostSavingsLost: 0
; CHECK: Threshold: 0
define amdgpu_kernel void @test_inliner_no_alloc(ptr addrspace(5) %a, ptr addrspace(5) %b) {
entry:
call void @use_both_externally(ptr addrspace(5) %a, ptr addrspace(5) %b)
ret void
}
declare void @external(ptr addrspace(5) %p)