brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 9bec92a Raw
95 lines · plain
1; RUN: opt -mtriple=amdgcn--amdhsa -S -passes=inline -inline-threshold=0 -debug-only=inline-cost %s 2>&1 | FileCheck %s2 3; REQUIRES: asserts4 5; Verify we are properly adding cost of the -amdgpu-inline-arg-alloca-cost to the threshold.6 7define void @local_access_only(ptr addrspace(5) %p, i32 %idx) {8  %arrayidx = getelementptr inbounds [64 x float], ptr addrspace(5) %p, i32 0, i32 %idx9  %value = load float, ptr addrspace(5) %arrayidx10  store float %value , ptr addrspace(5) %arrayidx, align 411  ret void12}13 14; Below the cutoff, the alloca cost is 0, and only the cost of the instructions saved by sroa is counted15; CHECK: Analyzing call of local_access_only... (caller:test_inliner_sroa_single_below_cutoff)16; CHECK: NumAllocaArgs: 117; CHECK: SROACostSavings: 1018; CHECK: SROACostSavingsLost: 019; CHECK: Threshold: 6600020define amdgpu_kernel void @test_inliner_sroa_single_below_cutoff(ptr addrspace(1) %a, i32 %n) {21entry:22  %pvt_arr = alloca [64 x float], align 4, addrspace(5)23  call void @local_access_only(ptr addrspace(5) %pvt_arr, i32 4)24  ret void25}26 27; Above the cutoff, attribute a cost to the alloca28; CHECK: Analyzing call of local_access_only... (caller:test_inliner_sroa_single_above_cutoff)29; CHECK: NumAllocaArgs: 130; CHECK: SROACostSavings: 6601031; CHECK: SROACostSavingsLost: 032; CHECK: Threshold: 6600033define amdgpu_kernel void @test_inliner_sroa_single_above_cutoff(ptr addrspace(1) %a, i32 %n) {34entry:35  %pvt_arr = alloca [65 x float], align 4, addrspace(5)36  call void @local_access_only(ptr addrspace(5) %pvt_arr, i32 4)37  ret void38}39 40define void @use_first_externally(ptr addrspace(5) %p1, ptr addrspace(5) %p2) {41  call void @external(ptr addrspace(5) %p1)42  %arrayidx = getelementptr inbounds [64 x float], ptr addrspace(5) %p2, i32 0, i32 743  %value = load float, ptr addrspace(5) %arrayidx44  store float %value , ptr addrspace(5) %arrayidx, align 445  ret void46}47 48define void @use_both_externally(ptr addrspace(5) %p1, ptr addrspace(5) %p2) {49  call void @external(ptr addrspace(5) %p1)50  call void @external(ptr addrspace(5) %p2)51  ret void52}53 54; One array cannot get handled by SROA 55; CHECK: Analyzing call of use_first_externally... (caller:test_inliner_sroa_double)56; CHECK: NumAllocaArgs: 257; CHECK: SROACostSavings: 3250258; CHECK: SROACostSavingsLost: 3350759; CHECK: Threshold: 6600060define amdgpu_kernel void @test_inliner_sroa_double() {61entry:62  %pvt_arr1 = alloca [33 x float], align 4, addrspace(5)63  %pvt_arr2 = alloca [32 x float], align 4, addrspace(5)64  call void @use_first_externally(ptr addrspace(5) %pvt_arr1, ptr addrspace(5) %pvt_arr2)65  ret void66}67 68; The two arrays cannot get handled by SROA 69; CHECK: Analyzing call of use_both_externally... (caller:test_inliner_no_sroa)70; CHECK: NumAllocaArgs: 271; CHECK: SROACostSavings: 072; CHECK: SROACostSavingsLost: 6599973; CHECK: Threshold: 6600074define amdgpu_kernel void @test_inliner_no_sroa() {75entry:76  %pvt_arr1 = alloca [33 x float], align 4, addrspace(5)77  %pvt_arr2 = alloca [32 x float], align 4, addrspace(5)78  call void @use_both_externally(ptr addrspace(5) %pvt_arr1, ptr addrspace(5) %pvt_arr2)79  ret void80}81 82; No private arrays83; CHECK: Analyzing call of use_both_externally... (caller:test_inliner_no_alloc)84; CHECK: NumAllocaArgs: 085; CHECK: SROACostSavings: 086; CHECK: SROACostSavingsLost: 087; CHECK: Threshold: 088define amdgpu_kernel void @test_inliner_no_alloc(ptr addrspace(5) %a, ptr addrspace(5) %b) {89entry:90  call void @use_both_externally(ptr addrspace(5) %a, ptr addrspace(5) %b)91  ret void92}93 94declare void @external(ptr addrspace(5) %p)95