Matt Arsenault | a680199 | 2018-07-10 14:03:41 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-function-calls -amdgpu-always-inline %s | FileCheck -check-prefixes=CALLS-ENABLED,ALL %s |
| 2 | ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-function-calls -amdgpu-stress-function-calls -amdgpu-always-inline %s | FileCheck -check-prefixes=STRESS-CALLS,ALL %s |
| 3 | |
Matt Arsenault | 9de2fb5 | 2018-09-13 11:56:28 +0000 | [diff] [blame] | 4 | target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-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" |
Matt Arsenault | a680199 | 2018-07-10 14:03:41 +0000 | [diff] [blame] | 5 | |
| 6 | @lds0 = addrspace(3) global i32 undef, align 4 |
| 7 | @lds1 = addrspace(3) global [512 x i32] undef, align 4 |
| 8 | @nested.lds.address = addrspace(1) global i32 addrspace(3)* @lds0, align 4 |
| 9 | @gds0 = addrspace(2) global i32 undef, align 4 |
| 10 | |
| 11 | @alias.lds0 = alias i32, i32 addrspace(3)* @lds0 |
| 12 | @lds.cycle = addrspace(3) global i32 ptrtoint (i32 addrspace(3)* @lds.cycle to i32), align 4 |
| 13 | |
| 14 | |
| 15 | ; ALL-LABEL: define i32 @load_lds_simple() #0 { |
| 16 | define i32 @load_lds_simple() { |
| 17 | %load = load i32, i32 addrspace(3)* @lds0, align 4 |
| 18 | ret i32 %load |
| 19 | } |
| 20 | |
| 21 | ; ALL-LABEL: define i32 @load_gds_simple() #0 { |
| 22 | define i32 @load_gds_simple() { |
| 23 | %load = load i32, i32 addrspace(2)* @gds0, align 4 |
| 24 | ret i32 %load |
| 25 | } |
| 26 | |
| 27 | ; ALL-LABEL: define i32 @load_lds_const_gep() #0 { |
| 28 | define i32 @load_lds_const_gep() { |
| 29 | %load = load i32, i32 addrspace(3)* getelementptr inbounds ([512 x i32], [512 x i32] addrspace(3)* @lds1, i64 0, i64 4), align 4 |
| 30 | ret i32 %load |
| 31 | } |
| 32 | |
| 33 | ; ALL-LABEL: define i32 @load_lds_var_gep(i32 %idx) #0 { |
| 34 | define i32 @load_lds_var_gep(i32 %idx) { |
| 35 | %gep = getelementptr inbounds [512 x i32], [512 x i32] addrspace(3)* @lds1, i32 0, i32 %idx |
| 36 | %load = load i32, i32 addrspace(3)* %gep, align 4 |
| 37 | ret i32 %load |
| 38 | } |
| 39 | |
| 40 | ; ALL-LABEL: define i32 addrspace(3)* @load_nested_address(i32 %idx) #0 { |
| 41 | define i32 addrspace(3)* @load_nested_address(i32 %idx) { |
| 42 | %load = load i32 addrspace(3)*, i32 addrspace(3)* addrspace(1)* @nested.lds.address, align 4 |
| 43 | ret i32 addrspace(3)* %load |
| 44 | } |
| 45 | |
| 46 | ; ALL-LABEL: define i32 @load_lds_alias() #0 { |
| 47 | define i32 @load_lds_alias() { |
| 48 | %load = load i32, i32 addrspace(3)* @alias.lds0, align 4 |
| 49 | ret i32 %load |
| 50 | } |
| 51 | |
| 52 | ; ALL-LABEL: define i32 @load_lds_cycle() #0 { |
| 53 | define i32 @load_lds_cycle() { |
| 54 | %load = load i32, i32 addrspace(3)* @lds.cycle, align 4 |
| 55 | ret i32 %load |
| 56 | } |
| 57 | |
| 58 | ; ALL-LABEL: define i1 @icmp_lds_address() #0 { |
| 59 | define i1 @icmp_lds_address() { |
| 60 | ret i1 icmp eq (i32 addrspace(3)* @lds0, i32 addrspace(3)* null) |
| 61 | } |
| 62 | |
| 63 | ; ALL-LABEL: define i32 @transitive_call() #0 { |
| 64 | define i32 @transitive_call() { |
| 65 | %call = call i32 @load_lds_simple() |
| 66 | ret i32 %call |
| 67 | } |
| 68 | |
| 69 | ; ALL-LABEL: define i32 @recursive_call_lds(i32 %arg0) #0 { |
| 70 | define i32 @recursive_call_lds(i32 %arg0) { |
| 71 | %load = load i32, i32 addrspace(3)* @lds0, align 4 |
| 72 | %add = add i32 %arg0, %load |
| 73 | %call = call i32 @recursive_call_lds(i32 %add) |
| 74 | ret i32 %call |
| 75 | } |
| 76 | |
| 77 | ; ALL: attributes #0 = { alwaysinline } |