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
4 @compute_lds = external addrspace(3) global [512 x i32], align 16
6 ; GCN-LABEL: {{^}}store_aligned:
8 define amdgpu_cs void @store_aligned(i32 addrspace(3)* %ptr) #0 {
10 %ptr.gep.1 = getelementptr i32, i32 addrspace(3)* %ptr, i32 1
12 store i32 42, i32 addrspace(3)* %ptr, align 8
13 store i32 43, i32 addrspace(3)* %ptr.gep.1
18 ; GCN-LABEL: {{^}}load_aligned:
20 define amdgpu_cs <2 x float> @load_aligned(i32 addrspace(3)* %ptr) #0 {
22 %ptr.gep.1 = getelementptr i32, i32 addrspace(3)* %ptr, i32 1
24 %v.0 = load i32, i32 addrspace(3)* %ptr, align 8
25 %v.1 = load i32, i32 addrspace(3)* %ptr.gep.1
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>
34 ; GCN-LABEL: {{^}}store_global_const_idx:
36 define amdgpu_cs void @store_global_const_idx() #0 {
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
41 store i32 42, i32 addrspace(3)* %ptr.a
42 store i32 43, i32 addrspace(3)* %ptr.b
47 ; GCN-LABEL: {{^}}load_global_const_idx:
49 define amdgpu_cs <2 x float> @load_global_const_idx() #0 {
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
54 %v.0 = load i32, i32 addrspace(3)* %ptr.a
55 %v.1 = load i32, i32 addrspace(3)* %ptr.b
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>
64 ; GCN-LABEL: {{^}}store_global_var_idx_case1:
67 ; NONSI: ds_write2_b32
68 define amdgpu_cs void @store_global_var_idx_case1(i32 %idx) #0 {
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
73 store i32 42, i32 addrspace(3)* %ptr.a
74 store i32 43, i32 addrspace(3)* %ptr.b
79 ; GCN-LABEL: {{^}}load_global_var_idx_case1:
83 define amdgpu_cs <2 x float> @load_global_var_idx_case1(i32 %idx) #0 {
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
88 %v.0 = load i32, i32 addrspace(3)* %ptr.a
89 %v.1 = load i32, i32 addrspace(3)* %ptr.b
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>
98 ; GCN-LABEL: {{^}}store_global_var_idx_case2:
100 define amdgpu_cs void @store_global_var_idx_case2(i32 %idx) #0 {
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
106 store i32 42, i32 addrspace(3)* %ptr.a
107 store i32 43, i32 addrspace(3)* %ptr.b
112 ; GCN-LABEL: {{^}}load_global_var_idx_case2:
114 define amdgpu_cs <2 x float> @load_global_var_idx_case2(i32 %idx) #0 {
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
120 %v.0 = load i32, i32 addrspace(3)* %ptr.a
121 %v.1 = load i32, i32 addrspace(3)* %ptr.b
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>
129 attributes #0 = { nounwind }