1 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
2 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
3 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-stress-function-calls -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
4 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-stress-function-calls -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
6 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
8 @lds0 = addrspace(3) global i32 undef, align 4
9 @lds1 = addrspace(3) global [512 x i32] undef, align 4
10 @nested.lds.address = addrspace(1) global ptr addrspace(3) @lds0, align 4
11 @gds0 = addrspace(2) global i32 undef, align 4
13 @alias.lds0 = alias i32, ptr addrspace(3) @lds0
14 @lds.cycle = addrspace(3) global i32 ptrtoint (ptr addrspace(3) @lds.cycle to i32), align 4
17 ; ALL-LABEL: define i32 @load_lds_simple() #0 {
18 define i32 @load_lds_simple() {
19 %load = load i32, ptr addrspace(3) @lds0, align 4
23 ; ALL-LABEL: define i32 @load_gds_simple() #0 {
24 define i32 @load_gds_simple() {
25 %load = load i32, ptr addrspace(2) @gds0, align 4
29 ; ALL-LABEL: define i32 @load_lds_const_gep() #0 {
30 define i32 @load_lds_const_gep() {
31 %load = load i32, ptr addrspace(3) getelementptr inbounds ([512 x i32], ptr addrspace(3) @lds1, i64 0, i64 4), align 4
35 ; ALL-LABEL: define i32 @load_lds_var_gep(i32 %idx) #0 {
36 define i32 @load_lds_var_gep(i32 %idx) {
37 %gep = getelementptr inbounds [512 x i32], ptr addrspace(3) @lds1, i32 0, i32 %idx
38 %load = load i32, ptr addrspace(3) %gep, align 4
42 ; ALL-LABEL: define ptr addrspace(3) @load_nested_address(i32 %idx) #0 {
43 define ptr addrspace(3) @load_nested_address(i32 %idx) {
44 %load = load ptr addrspace(3), ptr addrspace(1) @nested.lds.address, align 4
45 ret ptr addrspace(3) %load
48 ; ALL-LABEL: define i32 @load_lds_alias() #0 {
49 define i32 @load_lds_alias() {
50 %load = load i32, ptr addrspace(3) @alias.lds0, align 4
54 ; ALL-LABEL: define i32 @load_lds_cycle() #0 {
55 define i32 @load_lds_cycle() {
56 %load = load i32, ptr addrspace(3) @lds.cycle, align 4
60 ; ALL-LABEL: define i1 @icmp_lds_address() #0 {
61 define i1 @icmp_lds_address() {
62 %cmp = icmp eq ptr addrspace(3) @lds0, null
66 ; ALL-LABEL: define i32 @transitive_call() #0 {
67 define i32 @transitive_call() {
68 %call = call i32 @load_lds_simple()
72 ; ALL-LABEL: define i32 @recursive_call_lds(i32 %arg0) #0 {
73 define i32 @recursive_call_lds(i32 %arg0) {
74 %load = load i32, ptr addrspace(3) @lds0, align 4
75 %add = add i32 %arg0, %load
76 %call = call i32 @recursive_call_lds(i32 %add)
80 ; Test we don't break the IR and have both alwaysinline and noinline
81 ; FIXME: We should really not override noinline.
83 ; ALL-LABEL: define i32 @load_lds_simple_noinline() #0 {
84 define i32 @load_lds_simple_noinline() noinline {
85 %load = load i32, ptr addrspace(3) @lds0, align 4
89 ; ALL-LABEL: define i32 @recursive_call_lds_noinline(i32 %arg0) #0 {
90 define i32 @recursive_call_lds_noinline(i32 %arg0) noinline {
91 %load = load i32, ptr addrspace(3) @lds0, align 4
92 %add = add i32 %arg0, %load
93 %call = call i32 @recursive_call_lds(i32 %add)
97 ; ALL: attributes #0 = { alwaysinline }