Nicolai Haehnle | 4821937 | 2018-10-17 15:37:48 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,SI %s |
| 2 | ; RUN: llc -march=amdgcn -mcpu=hawaii -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,NOSI %s |
| 3 | |
| 4 | @compute_lds = external addrspace(3) global [512 x i32], align 16 |
| 5 | |
| 6 | ; GCN-LABEL: {{^}}store_aligned: |
| 7 | ; GCN: ds_write_b64 |
| 8 | define amdgpu_cs void @store_aligned(i32 addrspace(3)* %ptr) #0 { |
| 9 | entry: |
| 10 | %ptr.gep.1 = getelementptr i32, i32 addrspace(3)* %ptr, i32 1 |
| 11 | |
| 12 | store i32 42, i32 addrspace(3)* %ptr, align 8 |
| 13 | store i32 43, i32 addrspace(3)* %ptr.gep.1 |
| 14 | ret void |
| 15 | } |
| 16 | |
| 17 | |
| 18 | ; GCN-LABEL: {{^}}load_aligned: |
| 19 | ; GCN: ds_read_b64 |
| 20 | define amdgpu_cs <2 x float> @load_aligned(i32 addrspace(3)* %ptr) #0 { |
| 21 | entry: |
| 22 | %ptr.gep.1 = getelementptr i32, i32 addrspace(3)* %ptr, i32 1 |
| 23 | |
| 24 | %v.0 = load i32, i32 addrspace(3)* %ptr, align 8 |
| 25 | %v.1 = load i32, i32 addrspace(3)* %ptr.gep.1 |
| 26 | |
| 27 | %r.0 = insertelement <2 x i32> undef, i32 %v.0, i32 0 |
| 28 | %r.1 = insertelement <2 x i32> %r.0, i32 %v.1, i32 1 |
| 29 | %bc = bitcast <2 x i32> %r.1 to <2 x float> |
| 30 | ret <2 x float> %bc |
| 31 | } |
| 32 | |
| 33 | |
| 34 | ; GCN-LABEL: {{^}}store_global_const_idx: |
| 35 | ; GCN: ds_write2_b32 |
| 36 | define amdgpu_cs void @store_global_const_idx() #0 { |
| 37 | entry: |
| 38 | %ptr.a = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 3 |
| 39 | %ptr.b = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 4 |
| 40 | |
| 41 | store i32 42, i32 addrspace(3)* %ptr.a |
| 42 | store i32 43, i32 addrspace(3)* %ptr.b |
| 43 | ret void |
| 44 | } |
| 45 | |
| 46 | |
| 47 | ; GCN-LABEL: {{^}}load_global_const_idx: |
| 48 | ; GCN: ds_read2_b32 |
| 49 | define amdgpu_cs <2 x float> @load_global_const_idx() #0 { |
| 50 | entry: |
| 51 | %ptr.a = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 3 |
| 52 | %ptr.b = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 4 |
| 53 | |
| 54 | %v.0 = load i32, i32 addrspace(3)* %ptr.a |
| 55 | %v.1 = load i32, i32 addrspace(3)* %ptr.b |
| 56 | |
| 57 | %r.0 = insertelement <2 x i32> undef, i32 %v.0, i32 0 |
| 58 | %r.1 = insertelement <2 x i32> %r.0, i32 %v.1, i32 1 |
| 59 | %bc = bitcast <2 x i32> %r.1 to <2 x float> |
| 60 | ret <2 x float> %bc |
| 61 | } |
| 62 | |
| 63 | |
| 64 | ; GCN-LABEL: {{^}}store_global_var_idx_case1: |
| 65 | ; SI: ds_write_b32 |
| 66 | ; SI: ds_write_b32 |
| 67 | ; NONSI: ds_write2_b32 |
| 68 | define amdgpu_cs void @store_global_var_idx_case1(i32 %idx) #0 { |
| 69 | entry: |
| 70 | %ptr.a = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 %idx |
| 71 | %ptr.b = getelementptr i32, i32 addrspace(3)* %ptr.a, i32 1 |
| 72 | |
| 73 | store i32 42, i32 addrspace(3)* %ptr.a |
| 74 | store i32 43, i32 addrspace(3)* %ptr.b |
| 75 | ret void |
| 76 | } |
| 77 | |
| 78 | |
| 79 | ; GCN-LABEL: {{^}}load_global_var_idx_case1: |
| 80 | ; SI: ds_read_b32 |
| 81 | ; SI: ds_read_b32 |
| 82 | ; NONSI: ds_read2_b32 |
| 83 | define amdgpu_cs <2 x float> @load_global_var_idx_case1(i32 %idx) #0 { |
| 84 | entry: |
| 85 | %ptr.a = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 %idx |
| 86 | %ptr.b = getelementptr i32, i32 addrspace(3)* %ptr.a, i32 1 |
| 87 | |
| 88 | %v.0 = load i32, i32 addrspace(3)* %ptr.a |
| 89 | %v.1 = load i32, i32 addrspace(3)* %ptr.b |
| 90 | |
| 91 | %r.0 = insertelement <2 x i32> undef, i32 %v.0, i32 0 |
| 92 | %r.1 = insertelement <2 x i32> %r.0, i32 %v.1, i32 1 |
| 93 | %bc = bitcast <2 x i32> %r.1 to <2 x float> |
| 94 | ret <2 x float> %bc |
| 95 | } |
| 96 | |
| 97 | |
| 98 | ; GCN-LABEL: {{^}}store_global_var_idx_case2: |
| 99 | ; GCN: ds_write2_b32 |
| 100 | define amdgpu_cs void @store_global_var_idx_case2(i32 %idx) #0 { |
| 101 | entry: |
| 102 | %idx.and = and i32 %idx, 255 |
| 103 | %ptr.a = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 %idx.and |
| 104 | %ptr.b = getelementptr i32, i32 addrspace(3)* %ptr.a, i32 1 |
| 105 | |
| 106 | store i32 42, i32 addrspace(3)* %ptr.a |
| 107 | store i32 43, i32 addrspace(3)* %ptr.b |
| 108 | ret void |
| 109 | } |
| 110 | |
| 111 | |
| 112 | ; GCN-LABEL: {{^}}load_global_var_idx_case2: |
| 113 | ; GCN: ds_read2_b32 |
| 114 | define amdgpu_cs <2 x float> @load_global_var_idx_case2(i32 %idx) #0 { |
| 115 | entry: |
| 116 | %idx.and = and i32 %idx, 255 |
| 117 | %ptr.a = getelementptr [512 x i32], [512 x i32] addrspace(3)* @compute_lds, i32 0, i32 %idx.and |
| 118 | %ptr.b = getelementptr i32, i32 addrspace(3)* %ptr.a, i32 1 |
| 119 | |
| 120 | %v.0 = load i32, i32 addrspace(3)* %ptr.a |
| 121 | %v.1 = load i32, i32 addrspace(3)* %ptr.b |
| 122 | |
| 123 | %r.0 = insertelement <2 x i32> undef, i32 %v.0, i32 0 |
| 124 | %r.1 = insertelement <2 x i32> %r.0, i32 %v.1, i32 1 |
| 125 | %bc = bitcast <2 x i32> %r.1 to <2 x float> |
| 126 | ret <2 x float> %bc |
| 127 | } |
| 128 | |
| 129 | attributes #0 = { nounwind } |