Matt Arsenault | cdd191d | 2019-01-28 20:14:49 +0000 | [diff] [blame^] | 1 | ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,SI,NOTGFX9 %s |
| 2 | ; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,CIPLUS,NOTGFX9 %s |
| 3 | ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,CIPLUS,NOTGFX9 %s |
| 4 | ; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,CIPLUS,GFX9 %s |
| 5 | |
| 6 | ; GCN-LABEL: {{^}}ds_consume_lds: |
| 7 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 8 | ; GCN: s_mov_b32 m0, [[PTR]] |
| 9 | ; GCN: ds_consume [[RESULT:v[0-9]+]]{{$}} |
| 10 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 11 | define amdgpu_kernel void @ds_consume_lds(i32 addrspace(3)* %lds, i32 addrspace(1)* %out) #0 { |
| 12 | %val = call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %lds, i1 false) |
| 13 | store i32 %val, i32 addrspace(1)* %out |
| 14 | ret void |
| 15 | } |
| 16 | |
| 17 | ; GCN-LABEL: {{^}}ds_consume_lds_max_offset: |
| 18 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 19 | ; GCN: s_mov_b32 m0, [[PTR]] |
| 20 | ; GCN: ds_consume [[RESULT:v[0-9]+]] offset:65532{{$}} |
| 21 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 22 | define amdgpu_kernel void @ds_consume_lds_max_offset(i32 addrspace(3)* %lds, i32 addrspace(1)* %out) #0 { |
| 23 | %gep = getelementptr inbounds i32, i32 addrspace(3)* %lds, i32 16383 |
| 24 | %val = call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %gep, i1 false) |
| 25 | store i32 %val, i32 addrspace(1)* %out |
| 26 | ret void |
| 27 | } |
| 28 | |
| 29 | ; GCN-LABEL: {{^}}ds_consume_no_fold_offset_si: |
| 30 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 31 | |
| 32 | ; SI: s_add_i32 [[PTR]], [[PTR]], 16 |
| 33 | ; SI: s_mov_b32 m0, [[PTR]] |
| 34 | ; SI: ds_consume [[RESULT:v[0-9]+]]{{$}} |
| 35 | |
| 36 | ; CIPLUS: s_mov_b32 m0, [[PTR]] |
| 37 | ; CIPLUS: ds_consume [[RESULT:v[0-9]+]] offset:16{{$}} |
| 38 | |
| 39 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 40 | define amdgpu_kernel void @ds_consume_no_fold_offset_si(i32 addrspace(3)* addrspace(4)* %lds.ptr, i32 addrspace(1)* %out) #0 { |
| 41 | %lds = load i32 addrspace(3)*, i32 addrspace(3)* addrspace(4)* %lds.ptr, align 4 |
| 42 | %gep = getelementptr inbounds i32, i32 addrspace(3)* %lds, i32 4 |
| 43 | %val = call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %gep, i1 false) |
| 44 | store i32 %val, i32 addrspace(1)* %out |
| 45 | ret void |
| 46 | } |
| 47 | |
| 48 | ; GCN-LABEL: {{^}}ds_consume_lds_over_max_offset: |
| 49 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 50 | |
| 51 | ; SI: s_bitset1_b32 [[PTR]], 16 |
| 52 | ; CIPLUS: s_add_i32 [[PTR]], [[PTR]], 0x10000 |
| 53 | |
| 54 | ; GCN: s_mov_b32 m0, [[PTR]] |
| 55 | ; GCN: ds_consume [[RESULT:v[0-9]+]]{{$}} |
| 56 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 57 | define amdgpu_kernel void @ds_consume_lds_over_max_offset(i32 addrspace(3)* %lds, i32 addrspace(1)* %out) #0 { |
| 58 | %gep = getelementptr inbounds i32, i32 addrspace(3)* %lds, i32 16384 |
| 59 | %val = call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %gep, i1 false) |
| 60 | store i32 %val, i32 addrspace(1)* %out |
| 61 | ret void |
| 62 | } |
| 63 | |
| 64 | ; GCN-LABEL: {{^}}ds_consume_lds_vgpr_addr: |
| 65 | ; GCN: v_readfirstlane_b32 [[READLANE:s[0-9]+]], v0 |
| 66 | ; GCN: s_mov_b32 m0, [[READLANE]] |
| 67 | ; GCN: ds_consume [[RESULT:v[0-9]+]]{{$}} |
| 68 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 69 | define void @ds_consume_lds_vgpr_addr(i32 addrspace(3)* %lds, i32 addrspace(1)* %out) #0 { |
| 70 | %val = call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %lds, i1 false) |
| 71 | store i32 %val, i32 addrspace(1)* %out |
| 72 | ret void |
| 73 | } |
| 74 | |
| 75 | ; GCN-LABEL: {{^}}ds_consume_gds: |
| 76 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 77 | ; GCN: s_mov_b32 m0, [[PTR]] |
| 78 | ; GCN: ds_consume [[RESULT:v[0-9]+]] gds{{$}} |
| 79 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 80 | define amdgpu_kernel void @ds_consume_gds(i32 addrspace(2)* %gds, i32 addrspace(1)* %out) #0 { |
| 81 | %val = call i32 @llvm.amdgcn.ds.consume.p2i32(i32 addrspace(2)* %gds, i1 false) |
| 82 | store i32 %val, i32 addrspace(1)* %out |
| 83 | ret void |
| 84 | } |
| 85 | |
| 86 | ; GCN-LABEL: {{^}}ds_consume_gds_max_offset: |
| 87 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 88 | ; GCN: s_mov_b32 m0, [[PTR]] |
| 89 | ; GCN: ds_consume [[RESULT:v[0-9]+]] offset:65532 gds{{$}} |
| 90 | ; GCN: {{.*}}store{{.*}} [[RESULT]] |
| 91 | define amdgpu_kernel void @ds_consume_gds_max_offset(i32 addrspace(2)* %gds, i32 addrspace(1)* %out) #0 { |
| 92 | %gep = getelementptr inbounds i32, i32 addrspace(2)* %gds, i32 16383 |
| 93 | %val = call i32 @llvm.amdgcn.ds.consume.p2i32(i32 addrspace(2)* %gep, i1 false) |
| 94 | store i32 %val, i32 addrspace(1)* %out |
| 95 | ret void |
| 96 | } |
| 97 | |
| 98 | ; GCN-LABEL: {{^}}ds_consume_gds_over_max_offset: |
| 99 | define amdgpu_kernel void @ds_consume_gds_over_max_offset(i32 addrspace(2)* %gds, i32 addrspace(1)* %out) #0 { |
| 100 | %gep = getelementptr inbounds i32, i32 addrspace(2)* %gds, i32 16384 |
| 101 | %val = call i32 @llvm.amdgcn.ds.consume.p2i32(i32 addrspace(2)* %gep, i1 false) |
| 102 | store i32 %val, i32 addrspace(1)* %out |
| 103 | ret void |
| 104 | } |
| 105 | |
| 106 | ; GCN-LABEL: {{^}}ds_consume_lds_m0_restore: |
| 107 | ; GCN: s_load_dword [[PTR:s[0-9]+]] |
| 108 | ; GCN: s_mov_b32 m0, [[PTR]] |
| 109 | ; GCN: ds_consume [[RESULT:v[0-9]+]]{{$}} |
| 110 | ; NOTGFX9: s_mov_b32 m0, -1 |
| 111 | ; GFX9-NOT: m0 |
| 112 | ; GCN: _store_dword |
| 113 | ; GCN: ds_read_b32 |
| 114 | define amdgpu_kernel void @ds_consume_lds_m0_restore(i32 addrspace(3)* %lds, i32 addrspace(1)* %out) #0 { |
| 115 | %val0 = call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %lds, i1 false) |
| 116 | store i32 %val0, i32 addrspace(1)* %out |
| 117 | %val1 = load volatile i32, i32 addrspace(3)* %lds |
| 118 | ret void |
| 119 | } |
| 120 | |
| 121 | declare i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* nocapture, i1) #1 |
| 122 | declare i32 @llvm.amdgcn.ds.consume.p2i32(i32 addrspace(2)* nocapture, i1) #1 |
| 123 | |
| 124 | attributes #0 = { nounwind } |
| 125 | attributes #1 = { argmemonly convergent nounwind } |