blob: 2c474dbe7b086153f85def370f5489097230231d [file] [log] [blame]
Matt Arsenault84db5d92015-07-14 17:57:36 +00001; RUN: llc -march=amdgcn -mcpu=bonaire -verify-machineinstrs -mattr=+load-store-opt < %s | FileCheck -strict-whitespace -check-prefix=SI %s
Matt Arsenault41033282014-10-10 22:01:59 +00002
3; FIXME: We don't get cases where the address was an SGPR because we
4; get a copy to the address register for each one.
5
Matt Arsenaultcc8d3b82014-11-13 19:56:13 +00006@lds = addrspace(3) global [512 x float] undef, align 4
Matt Arsenault84db5d92015-07-14 17:57:36 +00007@lds.f64 = addrspace(3) global [512 x double] undef, align 8
Matt Arsenault41033282014-10-10 22:01:59 +00008
9; SI-LABEL: @simple_read2_f32
Tom Stellard1f3416a2015-04-08 01:09:19 +000010; SI: ds_read2_b32 v{{\[}}[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]{{\]}}, v{{[0-9]+}} offset1:8
Tom Stellard326d6ec2014-11-05 14:50:53 +000011; SI: s_waitcnt lgkmcnt(0)
12; SI: v_add_f32_e32 [[RESULT:v[0-9]+]], v[[HI_VREG]], v[[LO_VREG]]
13; SI: buffer_store_dword [[RESULT]]
14; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000015define amdgpu_kernel void @simple_read2_f32(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000016 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000017 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +000018 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000019 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +000020 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +000021 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000022 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +000023 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +000024 store float %sum, float addrspace(1)* %out.gep, align 4
25 ret void
26}
27
28; SI-LABEL: @simple_read2_f32_max_offset
Tom Stellard1f3416a2015-04-08 01:09:19 +000029; SI: ds_read2_b32 v{{\[}}[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]{{\]}}, v{{[0-9]+}} offset1:255
Tom Stellard326d6ec2014-11-05 14:50:53 +000030; SI: s_waitcnt lgkmcnt(0)
31; SI: v_add_f32_e32 [[RESULT:v[0-9]+]], v[[HI_VREG]], v[[LO_VREG]]
32; SI: buffer_store_dword [[RESULT]]
33; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000034define amdgpu_kernel void @simple_read2_f32_max_offset(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000035 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000036 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +000037 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000038 %add.x = add nsw i32 %x.i, 255
David Blaikie79e6c742015-02-27 19:29:02 +000039 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +000040 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000041 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +000042 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +000043 store float %sum, float addrspace(1)* %out.gep, align 4
44 ret void
45}
46
47; SI-LABEL: @simple_read2_f32_too_far
Tom Stellard326d6ec2014-11-05 14:50:53 +000048; SI-NOT ds_read2_b32
49; SI: ds_read_b32 v{{[0-9]+}}, v{{[0-9]+}}
50; SI: ds_read_b32 v{{[0-9]+}}, v{{[0-9]+}} offset:1028
51; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000052define amdgpu_kernel void @simple_read2_f32_too_far(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000053 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +000054 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +000055 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +000056 %add.x = add nsw i32 %x.i, 257
David Blaikie79e6c742015-02-27 19:29:02 +000057 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +000058 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000059 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +000060 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +000061 store float %sum, float addrspace(1)* %out.gep, align 4
62 ret void
63}
64
65; SI-LABEL: @simple_read2_f32_x2
Tom Stellard1f3416a2015-04-08 01:09:19 +000066; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASEADDR:v[0-9]+]] offset1:8
Tom Stellard326d6ec2014-11-05 14:50:53 +000067; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASEADDR]] offset0:11 offset1:27
68; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000069define amdgpu_kernel void @simple_read2_f32_x2(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000070 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +000071 %idx.0 = add nsw i32 %tid.x, 0
David Blaikie79e6c742015-02-27 19:29:02 +000072 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.0
David Blaikiea79ac142015-02-27 21:17:42 +000073 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000074
75 %idx.1 = add nsw i32 %tid.x, 8
David Blaikie79e6c742015-02-27 19:29:02 +000076 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.1
David Blaikiea79ac142015-02-27 21:17:42 +000077 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000078 %sum.0 = fadd float %val0, %val1
79
80 %idx.2 = add nsw i32 %tid.x, 11
David Blaikie79e6c742015-02-27 19:29:02 +000081 %arrayidx2 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.2
David Blaikiea79ac142015-02-27 21:17:42 +000082 %val2 = load float, float addrspace(3)* %arrayidx2, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000083
84 %idx.3 = add nsw i32 %tid.x, 27
David Blaikie79e6c742015-02-27 19:29:02 +000085 %arrayidx3 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.3
David Blaikiea79ac142015-02-27 21:17:42 +000086 %val3 = load float, float addrspace(3)* %arrayidx3, align 4
Matt Arsenault41033282014-10-10 22:01:59 +000087 %sum.1 = fadd float %val2, %val3
88
89 %sum = fadd float %sum.0, %sum.1
David Blaikie79e6c742015-02-27 19:29:02 +000090 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %idx.0
Matt Arsenault41033282014-10-10 22:01:59 +000091 store float %sum, float addrspace(1)* %out.gep, align 4
92 ret void
93}
94
95; Make sure there is an instruction between the two sets of reads.
96; SI-LABEL: @simple_read2_f32_x2_barrier
Tom Stellard1f3416a2015-04-08 01:09:19 +000097; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASEADDR:v[0-9]+]] offset1:8
Tom Stellard326d6ec2014-11-05 14:50:53 +000098; SI: s_barrier
99; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASEADDR]] offset0:11 offset1:27
100; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000101define amdgpu_kernel void @simple_read2_f32_x2_barrier(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000102 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000103 %idx.0 = add nsw i32 %tid.x, 0
David Blaikie79e6c742015-02-27 19:29:02 +0000104 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.0
David Blaikiea79ac142015-02-27 21:17:42 +0000105 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000106
107 %idx.1 = add nsw i32 %tid.x, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000108 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.1
David Blaikiea79ac142015-02-27 21:17:42 +0000109 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000110 %sum.0 = fadd float %val0, %val1
111
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000112 call void @llvm.amdgcn.s.barrier() #2
Matt Arsenault41033282014-10-10 22:01:59 +0000113
114 %idx.2 = add nsw i32 %tid.x, 11
David Blaikie79e6c742015-02-27 19:29:02 +0000115 %arrayidx2 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.2
David Blaikiea79ac142015-02-27 21:17:42 +0000116 %val2 = load float, float addrspace(3)* %arrayidx2, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000117
118 %idx.3 = add nsw i32 %tid.x, 27
David Blaikie79e6c742015-02-27 19:29:02 +0000119 %arrayidx3 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.3
David Blaikiea79ac142015-02-27 21:17:42 +0000120 %val3 = load float, float addrspace(3)* %arrayidx3, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000121 %sum.1 = fadd float %val2, %val3
122
123 %sum = fadd float %sum.0, %sum.1
David Blaikie79e6c742015-02-27 19:29:02 +0000124 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %idx.0
Matt Arsenault41033282014-10-10 22:01:59 +0000125 store float %sum, float addrspace(1)* %out.gep, align 4
126 ret void
127}
128
129; For some reason adding something to the base address for the first
130; element results in only folding the inner pair.
131
132; SI-LABEL: @simple_read2_f32_x2_nonzero_base
Tom Stellard326d6ec2014-11-05 14:50:53 +0000133; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASEADDR:v[0-9]+]] offset0:2 offset1:8
134; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASEADDR]] offset0:11 offset1:27
135; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000136define amdgpu_kernel void @simple_read2_f32_x2_nonzero_base(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000137 %tid.x = tail call i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000138 %idx.0 = add nsw i32 %tid.x, 2
David Blaikie79e6c742015-02-27 19:29:02 +0000139 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.0
David Blaikiea79ac142015-02-27 21:17:42 +0000140 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000141
142 %idx.1 = add nsw i32 %tid.x, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000143 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.1
David Blaikiea79ac142015-02-27 21:17:42 +0000144 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000145 %sum.0 = fadd float %val0, %val1
146
147 %idx.2 = add nsw i32 %tid.x, 11
David Blaikie79e6c742015-02-27 19:29:02 +0000148 %arrayidx2 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.2
David Blaikiea79ac142015-02-27 21:17:42 +0000149 %val2 = load float, float addrspace(3)* %arrayidx2, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000150
151 %idx.3 = add nsw i32 %tid.x, 27
David Blaikie79e6c742015-02-27 19:29:02 +0000152 %arrayidx3 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %idx.3
David Blaikiea79ac142015-02-27 21:17:42 +0000153 %val3 = load float, float addrspace(3)* %arrayidx3, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000154 %sum.1 = fadd float %val2, %val3
155
156 %sum = fadd float %sum.0, %sum.1
David Blaikie79e6c742015-02-27 19:29:02 +0000157 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %idx.0
Matt Arsenault41033282014-10-10 22:01:59 +0000158 store float %sum, float addrspace(1)* %out.gep, align 4
159 ret void
160}
161
162; Be careful of vectors of pointers. We don't know if the 2 pointers
163; in the vectors are really the same base, so this is not safe to
164; merge.
165; Base pointers come from different subregister of same super
166; register. We can't safely merge this.
167
168; SI-LABEL: @read2_ptr_is_subreg_arg_f32
Tom Stellard326d6ec2014-11-05 14:50:53 +0000169; SI-NOT: ds_read2_b32
170; SI: ds_read_b32
171; SI: ds_read_b32
172; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000173define amdgpu_kernel void @read2_ptr_is_subreg_arg_f32(float addrspace(1)* %out, <2 x float addrspace(3)*> %lds.ptr) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000174 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000175 %index.0 = insertelement <2 x i32> undef, i32 %x.i, i32 0
176 %index.1 = insertelement <2 x i32> %index.0, i32 8, i32 0
David Blaikie79e6c742015-02-27 19:29:02 +0000177 %gep = getelementptr inbounds float, <2 x float addrspace(3)*> %lds.ptr, <2 x i32> %index.1
Matt Arsenault41033282014-10-10 22:01:59 +0000178 %gep.0 = extractelement <2 x float addrspace(3)*> %gep, i32 0
179 %gep.1 = extractelement <2 x float addrspace(3)*> %gep, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +0000180 %val0 = load float, float addrspace(3)* %gep.0, align 4
181 %val1 = load float, float addrspace(3)* %gep.1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000182 %add.x = add nsw i32 %x.i, 8
183 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000184 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000185 store float %sum, float addrspace(1)* %out.gep, align 4
186 ret void
187}
188
189; Apply a constant scalar offset after the pointer vector extract. We
190; are rejecting merges that have the same, constant 0 offset, so make
191; sure we are really rejecting it because of the different
192; subregisters.
193
194; SI-LABEL: @read2_ptr_is_subreg_arg_offset_f32
Tom Stellard326d6ec2014-11-05 14:50:53 +0000195; SI-NOT: ds_read2_b32
196; SI: ds_read_b32
197; SI: ds_read_b32
198; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000199define amdgpu_kernel void @read2_ptr_is_subreg_arg_offset_f32(float addrspace(1)* %out, <2 x float addrspace(3)*> %lds.ptr) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000200 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000201 %index.0 = insertelement <2 x i32> undef, i32 %x.i, i32 0
202 %index.1 = insertelement <2 x i32> %index.0, i32 8, i32 0
David Blaikie79e6c742015-02-27 19:29:02 +0000203 %gep = getelementptr inbounds float, <2 x float addrspace(3)*> %lds.ptr, <2 x i32> %index.1
Matt Arsenault41033282014-10-10 22:01:59 +0000204 %gep.0 = extractelement <2 x float addrspace(3)*> %gep, i32 0
205 %gep.1 = extractelement <2 x float addrspace(3)*> %gep, i32 1
206
207 ; Apply an additional offset after the vector that will be more obviously folded.
David Blaikie79e6c742015-02-27 19:29:02 +0000208 %gep.1.offset = getelementptr float, float addrspace(3)* %gep.1, i32 8
Matt Arsenault41033282014-10-10 22:01:59 +0000209
David Blaikiea79ac142015-02-27 21:17:42 +0000210 %val0 = load float, float addrspace(3)* %gep.0, align 4
211 %val1 = load float, float addrspace(3)* %gep.1.offset, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000212 %add.x = add nsw i32 %x.i, 8
213 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000214 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000215 store float %sum, float addrspace(1)* %out.gep, align 4
216 ret void
217}
218
Matt Arsenault61dc2352015-10-12 23:59:50 +0000219; SI-LABEL: {{^}}read2_ptr_is_subreg_f32:
220; SI: ds_read2_b32 {{v\[[0-9]+:[0-9]+\]}}, {{v[0-9]+}} offset1:8{{$}}
Tom Stellard326d6ec2014-11-05 14:50:53 +0000221; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000222define amdgpu_kernel void @read2_ptr_is_subreg_f32(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000223 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000224 %ptr.0 = insertelement <2 x [512 x float] addrspace(3)*> undef, [512 x float] addrspace(3)* @lds, i32 0
225 %ptr.1 = insertelement <2 x [512 x float] addrspace(3)*> %ptr.0, [512 x float] addrspace(3)* @lds, i32 1
226 %x.i.v.0 = insertelement <2 x i32> undef, i32 %x.i, i32 0
227 %x.i.v.1 = insertelement <2 x i32> %x.i.v.0, i32 %x.i, i32 1
228 %idx = add <2 x i32> %x.i.v.1, <i32 0, i32 8>
David Blaikie79e6c742015-02-27 19:29:02 +0000229 %gep = getelementptr inbounds [512 x float], <2 x [512 x float] addrspace(3)*> %ptr.1, <2 x i32> <i32 0, i32 0>, <2 x i32> %idx
Matt Arsenault41033282014-10-10 22:01:59 +0000230 %gep.0 = extractelement <2 x float addrspace(3)*> %gep, i32 0
231 %gep.1 = extractelement <2 x float addrspace(3)*> %gep, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +0000232 %val0 = load float, float addrspace(3)* %gep.0, align 4
233 %val1 = load float, float addrspace(3)* %gep.1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000234 %add.x = add nsw i32 %x.i, 8
235 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000236 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000237 store float %sum, float addrspace(1)* %out.gep, align 4
238 ret void
239}
240
241; SI-LABEL: @simple_read2_f32_volatile_0
Tom Stellard326d6ec2014-11-05 14:50:53 +0000242; SI-NOT ds_read2_b32
243; SI: ds_read_b32 v{{[0-9]+}}, v{{[0-9]+}}
244; SI: ds_read_b32 v{{[0-9]+}}, v{{[0-9]+}} offset:32
245; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000246define amdgpu_kernel void @simple_read2_f32_volatile_0(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000247 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000248 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000249 %val0 = load volatile float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000250 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000251 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000252 %val1 = load float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000253 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000254 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000255 store float %sum, float addrspace(1)* %out.gep, align 4
256 ret void
257}
258
259; SI-LABEL: @simple_read2_f32_volatile_1
Tom Stellard326d6ec2014-11-05 14:50:53 +0000260; SI-NOT ds_read2_b32
261; SI: ds_read_b32 v{{[0-9]+}}, v{{[0-9]+}}
262; SI: ds_read_b32 v{{[0-9]+}}, v{{[0-9]+}} offset:32
263; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000264define amdgpu_kernel void @simple_read2_f32_volatile_1(float addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000265 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000266 %arrayidx0 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000267 %val0 = load float, float addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000268 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000269 %arrayidx1 = getelementptr inbounds [512 x float], [512 x float] addrspace(3)* @lds, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000270 %val1 = load volatile float, float addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000271 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000272 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000273 store float %sum, float addrspace(1)* %out.gep, align 4
274 ret void
275}
276
277; Can't fold since not correctly aligned.
278; XXX: This isn't really testing anything useful now. I think CI
279; allows unaligned LDS accesses, which would be a problem here.
280; SI-LABEL: @unaligned_read2_f32
Tom Stellard326d6ec2014-11-05 14:50:53 +0000281; SI-NOT: ds_read2_b32
282; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000283define amdgpu_kernel void @unaligned_read2_f32(float addrspace(1)* %out, float addrspace(3)* %lds) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000284 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000285 %arrayidx0 = getelementptr inbounds float, float addrspace(3)* %lds, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000286 %val0 = load float, float addrspace(3)* %arrayidx0, align 1
Matt Arsenault41033282014-10-10 22:01:59 +0000287 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000288 %arrayidx1 = getelementptr inbounds float, float addrspace(3)* %lds, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000289 %val1 = load float, float addrspace(3)* %arrayidx1, align 1
Matt Arsenault41033282014-10-10 22:01:59 +0000290 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000291 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000292 store float %sum, float addrspace(1)* %out.gep, align 4
293 ret void
294}
295
296; SI-LABEL: @misaligned_2_simple_read2_f32
Tom Stellard326d6ec2014-11-05 14:50:53 +0000297; SI-NOT: ds_read2_b32
298; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000299define amdgpu_kernel void @misaligned_2_simple_read2_f32(float addrspace(1)* %out, float addrspace(3)* %lds) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000300 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000301 %arrayidx0 = getelementptr inbounds float, float addrspace(3)* %lds, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000302 %val0 = load float, float addrspace(3)* %arrayidx0, align 2
Matt Arsenault41033282014-10-10 22:01:59 +0000303 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000304 %arrayidx1 = getelementptr inbounds float, float addrspace(3)* %lds, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000305 %val1 = load float, float addrspace(3)* %arrayidx1, align 2
Matt Arsenault41033282014-10-10 22:01:59 +0000306 %sum = fadd float %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000307 %out.gep = getelementptr inbounds float, float addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000308 store float %sum, float addrspace(1)* %out.gep, align 4
309 ret void
310}
311
312; SI-LABEL: @simple_read2_f64
Tom Stellard326d6ec2014-11-05 14:50:53 +0000313; SI: v_lshlrev_b32_e32 [[VPTR:v[0-9]+]], 3, {{v[0-9]+}}
Tom Stellard1f3416a2015-04-08 01:09:19 +0000314; SI: ds_read2_b64 v{{\[}}[[LO_VREG:[0-9]+]]:[[HI_VREG:[0-9]+]]{{\]}}, [[VPTR]] offset1:8
Tom Stellard326d6ec2014-11-05 14:50:53 +0000315; SI: v_add_f64 [[RESULT:v\[[0-9]+:[0-9]+\]]], v{{\[}}[[LO_VREG]]:{{[0-9]+\]}}, v{{\[[0-9]+}}:[[HI_VREG]]{{\]}}
316; SI: buffer_store_dwordx2 [[RESULT]]
317; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000318define amdgpu_kernel void @simple_read2_f64(double addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000319 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000320 %arrayidx0 = getelementptr inbounds [512 x double], [512 x double] addrspace(3)* @lds.f64, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000321 %val0 = load double, double addrspace(3)* %arrayidx0, align 8
Matt Arsenault41033282014-10-10 22:01:59 +0000322 %add.x = add nsw i32 %x.i, 8
David Blaikie79e6c742015-02-27 19:29:02 +0000323 %arrayidx1 = getelementptr inbounds [512 x double], [512 x double] addrspace(3)* @lds.f64, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000324 %val1 = load double, double addrspace(3)* %arrayidx1, align 8
Matt Arsenault41033282014-10-10 22:01:59 +0000325 %sum = fadd double %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000326 %out.gep = getelementptr inbounds double, double addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000327 store double %sum, double addrspace(1)* %out.gep, align 8
328 ret void
329}
330
331; SI-LABEL: @simple_read2_f64_max_offset
Tom Stellard1f3416a2015-04-08 01:09:19 +0000332; SI: ds_read2_b64 {{v\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}} offset1:255
Tom Stellard326d6ec2014-11-05 14:50:53 +0000333; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000334define amdgpu_kernel void @simple_read2_f64_max_offset(double addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000335 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000336 %arrayidx0 = getelementptr inbounds [512 x double], [512 x double] addrspace(3)* @lds.f64, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000337 %val0 = load double, double addrspace(3)* %arrayidx0, align 8
Matt Arsenault41033282014-10-10 22:01:59 +0000338 %add.x = add nsw i32 %x.i, 255
David Blaikie79e6c742015-02-27 19:29:02 +0000339 %arrayidx1 = getelementptr inbounds [512 x double], [512 x double] addrspace(3)* @lds.f64, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000340 %val1 = load double, double addrspace(3)* %arrayidx1, align 8
Matt Arsenault41033282014-10-10 22:01:59 +0000341 %sum = fadd double %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000342 %out.gep = getelementptr inbounds double, double addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000343 store double %sum, double addrspace(1)* %out.gep, align 8
344 ret void
345}
346
347; SI-LABEL: @simple_read2_f64_too_far
Tom Stellard326d6ec2014-11-05 14:50:53 +0000348; SI-NOT ds_read2_b64
349; SI: ds_read_b64 {{v\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}}
350; SI: ds_read_b64 {{v\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}} offset:2056
351; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000352define amdgpu_kernel void @simple_read2_f64_too_far(double addrspace(1)* %out) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000353 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000354 %arrayidx0 = getelementptr inbounds [512 x double], [512 x double] addrspace(3)* @lds.f64, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000355 %val0 = load double, double addrspace(3)* %arrayidx0, align 8
Matt Arsenaultfe0a2e62014-10-10 22:12:32 +0000356 %add.x = add nsw i32 %x.i, 257
David Blaikie79e6c742015-02-27 19:29:02 +0000357 %arrayidx1 = getelementptr inbounds [512 x double], [512 x double] addrspace(3)* @lds.f64, i32 0, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000358 %val1 = load double, double addrspace(3)* %arrayidx1, align 8
Matt Arsenault41033282014-10-10 22:01:59 +0000359 %sum = fadd double %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000360 %out.gep = getelementptr inbounds double, double addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000361 store double %sum, double addrspace(1)* %out.gep, align 8
362 ret void
363}
364
365; Alignment only 4
366; SI-LABEL: @misaligned_read2_f64
Tom Stellard1f3416a2015-04-08 01:09:19 +0000367; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, {{v[0-9]+}} offset1:1
Tom Stellard326d6ec2014-11-05 14:50:53 +0000368; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, {{v[0-9]+}} offset0:14 offset1:15
369; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000370define amdgpu_kernel void @misaligned_read2_f64(double addrspace(1)* %out, double addrspace(3)* %lds) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000371 %x.i = tail call i32 @llvm.amdgcn.workitem.id.x() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000372 %arrayidx0 = getelementptr inbounds double, double addrspace(3)* %lds, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000373 %val0 = load double, double addrspace(3)* %arrayidx0, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000374 %add.x = add nsw i32 %x.i, 7
David Blaikie79e6c742015-02-27 19:29:02 +0000375 %arrayidx1 = getelementptr inbounds double, double addrspace(3)* %lds, i32 %add.x
David Blaikiea79ac142015-02-27 21:17:42 +0000376 %val1 = load double, double addrspace(3)* %arrayidx1, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000377 %sum = fadd double %val0, %val1
David Blaikie79e6c742015-02-27 19:29:02 +0000378 %out.gep = getelementptr inbounds double, double addrspace(1)* %out, i32 %x.i
Matt Arsenault41033282014-10-10 22:01:59 +0000379 store double %sum, double addrspace(1)* %out.gep, align 4
380 ret void
381}
382
Matt Arsenaultcc8d3b82014-11-13 19:56:13 +0000383@foo = addrspace(3) global [4 x i32] undef, align 4
Matt Arsenaulte775f5f2014-10-14 17:21:19 +0000384
385; SI-LABEL: @load_constant_adjacent_offsets
Tom Stellard326d6ec2014-11-05 14:50:53 +0000386; SI: v_mov_b32_e32 [[ZERO:v[0-9]+]], 0{{$}}
Tom Stellard1f3416a2015-04-08 01:09:19 +0000387; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[ZERO]] offset1:1
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000388define amdgpu_kernel void @load_constant_adjacent_offsets(i32 addrspace(1)* %out) {
David Blaikief72d05b2015-03-13 18:20:45 +0000389 %val0 = load i32, i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @foo, i32 0, i32 0), align 4
390 %val1 = load i32, i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @foo, i32 0, i32 1), align 4
Matt Arsenaulte775f5f2014-10-14 17:21:19 +0000391 %sum = add i32 %val0, %val1
392 store i32 %sum, i32 addrspace(1)* %out, align 4
393 ret void
394}
395
396; SI-LABEL: @load_constant_disjoint_offsets
Tom Stellard326d6ec2014-11-05 14:50:53 +0000397; SI: v_mov_b32_e32 [[ZERO:v[0-9]+]], 0{{$}}
Tom Stellard1f3416a2015-04-08 01:09:19 +0000398; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[ZERO]] offset1:2
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000399define amdgpu_kernel void @load_constant_disjoint_offsets(i32 addrspace(1)* %out) {
David Blaikief72d05b2015-03-13 18:20:45 +0000400 %val0 = load i32, i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @foo, i32 0, i32 0), align 4
401 %val1 = load i32, i32 addrspace(3)* getelementptr inbounds ([4 x i32], [4 x i32] addrspace(3)* @foo, i32 0, i32 2), align 4
Matt Arsenaulte775f5f2014-10-14 17:21:19 +0000402 %sum = add i32 %val0, %val1
403 store i32 %sum, i32 addrspace(1)* %out, align 4
404 ret void
405}
406
Matt Arsenaultcc8d3b82014-11-13 19:56:13 +0000407@bar = addrspace(3) global [4 x i64] undef, align 4
Matt Arsenault1a74aff2014-10-15 18:06:43 +0000408
409; SI-LABEL: @load_misaligned64_constant_offsets
Tom Stellard326d6ec2014-11-05 14:50:53 +0000410; SI: v_mov_b32_e32 [[ZERO:v[0-9]+]], 0{{$}}
Tom Stellard1f3416a2015-04-08 01:09:19 +0000411; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[ZERO]] offset1:1
Tom Stellard326d6ec2014-11-05 14:50:53 +0000412; SI: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[ZERO]] offset0:2 offset1:3
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000413define amdgpu_kernel void @load_misaligned64_constant_offsets(i64 addrspace(1)* %out) {
David Blaikief72d05b2015-03-13 18:20:45 +0000414 %val0 = load i64, i64 addrspace(3)* getelementptr inbounds ([4 x i64], [4 x i64] addrspace(3)* @bar, i32 0, i32 0), align 4
415 %val1 = load i64, i64 addrspace(3)* getelementptr inbounds ([4 x i64], [4 x i64] addrspace(3)* @bar, i32 0, i32 1), align 4
Matt Arsenault1a74aff2014-10-15 18:06:43 +0000416 %sum = add i64 %val0, %val1
417 store i64 %sum, i64 addrspace(1)* %out, align 8
418 ret void
419}
420
Matt Arsenaultcc8d3b82014-11-13 19:56:13 +0000421@bar.large = addrspace(3) global [4096 x i64] undef, align 4
Matt Arsenault1a74aff2014-10-15 18:06:43 +0000422
423; SI-LABEL: @load_misaligned64_constant_large_offsets
Tom Stellard326d6ec2014-11-05 14:50:53 +0000424; SI-DAG: v_mov_b32_e32 [[BASE0:v[0-9]+]], 0x7ff8{{$}}
425; SI-DAG: v_mov_b32_e32 [[BASE1:v[0-9]+]], 0x4000
Tom Stellard1f3416a2015-04-08 01:09:19 +0000426; SI-DAG: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASE0]] offset1:1
427; SI-DAG: ds_read2_b32 v{{\[[0-9]+:[0-9]+\]}}, [[BASE1]] offset1:1
Tom Stellard326d6ec2014-11-05 14:50:53 +0000428; SI: s_endpgm
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000429define amdgpu_kernel void @load_misaligned64_constant_large_offsets(i64 addrspace(1)* %out) {
David Blaikief72d05b2015-03-13 18:20:45 +0000430 %val0 = load i64, i64 addrspace(3)* getelementptr inbounds ([4096 x i64], [4096 x i64] addrspace(3)* @bar.large, i32 0, i32 2048), align 4
431 %val1 = load i64, i64 addrspace(3)* getelementptr inbounds ([4096 x i64], [4096 x i64] addrspace(3)* @bar.large, i32 0, i32 4095), align 4
Matt Arsenault1a74aff2014-10-15 18:06:43 +0000432 %sum = add i64 %val0, %val1
433 store i64 %sum, i64 addrspace(1)* %out, align 8
434 ret void
435}
436
Matt Arsenaultcc8d3b82014-11-13 19:56:13 +0000437@sgemm.lA = internal unnamed_addr addrspace(3) global [264 x float] undef, align 4
438@sgemm.lB = internal unnamed_addr addrspace(3) global [776 x float] undef, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000439
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000440define amdgpu_kernel void @sgemm_inner_loop_read2_sequence(float addrspace(1)* %C, i32 %lda, i32 %ldb) #0 {
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000441 %x.i = tail call i32 @llvm.amdgcn.workgroup.id.x() #1
442 %y.i = tail call i32 @llvm.amdgcn.workitem.id.y() #1
David Blaikie79e6c742015-02-27 19:29:02 +0000443 %arrayidx44 = getelementptr inbounds [264 x float], [264 x float] addrspace(3)* @sgemm.lA, i32 0, i32 %x.i
David Blaikiea79ac142015-02-27 21:17:42 +0000444 %tmp16 = load float, float addrspace(3)* %arrayidx44, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000445 %add47 = add nsw i32 %x.i, 1
David Blaikie79e6c742015-02-27 19:29:02 +0000446 %arrayidx48 = getelementptr inbounds [264 x float], [264 x float] addrspace(3)* @sgemm.lA, i32 0, i32 %add47
David Blaikiea79ac142015-02-27 21:17:42 +0000447 %tmp17 = load float, float addrspace(3)* %arrayidx48, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000448 %add51 = add nsw i32 %x.i, 16
David Blaikie79e6c742015-02-27 19:29:02 +0000449 %arrayidx52 = getelementptr inbounds [264 x float], [264 x float] addrspace(3)* @sgemm.lA, i32 0, i32 %add51
David Blaikiea79ac142015-02-27 21:17:42 +0000450 %tmp18 = load float, float addrspace(3)* %arrayidx52, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000451 %add55 = add nsw i32 %x.i, 17
David Blaikie79e6c742015-02-27 19:29:02 +0000452 %arrayidx56 = getelementptr inbounds [264 x float], [264 x float] addrspace(3)* @sgemm.lA, i32 0, i32 %add55
David Blaikiea79ac142015-02-27 21:17:42 +0000453 %tmp19 = load float, float addrspace(3)* %arrayidx56, align 4
David Blaikie79e6c742015-02-27 19:29:02 +0000454 %arrayidx60 = getelementptr inbounds [776 x float], [776 x float] addrspace(3)* @sgemm.lB, i32 0, i32 %y.i
David Blaikiea79ac142015-02-27 21:17:42 +0000455 %tmp20 = load float, float addrspace(3)* %arrayidx60, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000456 %add63 = add nsw i32 %y.i, 1
David Blaikie79e6c742015-02-27 19:29:02 +0000457 %arrayidx64 = getelementptr inbounds [776 x float], [776 x float] addrspace(3)* @sgemm.lB, i32 0, i32 %add63
David Blaikiea79ac142015-02-27 21:17:42 +0000458 %tmp21 = load float, float addrspace(3)* %arrayidx64, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000459 %add67 = add nsw i32 %y.i, 32
David Blaikie79e6c742015-02-27 19:29:02 +0000460 %arrayidx68 = getelementptr inbounds [776 x float], [776 x float] addrspace(3)* @sgemm.lB, i32 0, i32 %add67
David Blaikiea79ac142015-02-27 21:17:42 +0000461 %tmp22 = load float, float addrspace(3)* %arrayidx68, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000462 %add71 = add nsw i32 %y.i, 33
David Blaikie79e6c742015-02-27 19:29:02 +0000463 %arrayidx72 = getelementptr inbounds [776 x float], [776 x float] addrspace(3)* @sgemm.lB, i32 0, i32 %add71
David Blaikiea79ac142015-02-27 21:17:42 +0000464 %tmp23 = load float, float addrspace(3)* %arrayidx72, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000465 %add75 = add nsw i32 %y.i, 64
David Blaikie79e6c742015-02-27 19:29:02 +0000466 %arrayidx76 = getelementptr inbounds [776 x float], [776 x float] addrspace(3)* @sgemm.lB, i32 0, i32 %add75
David Blaikiea79ac142015-02-27 21:17:42 +0000467 %tmp24 = load float, float addrspace(3)* %arrayidx76, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000468 %add79 = add nsw i32 %y.i, 65
David Blaikie79e6c742015-02-27 19:29:02 +0000469 %arrayidx80 = getelementptr inbounds [776 x float], [776 x float] addrspace(3)* @sgemm.lB, i32 0, i32 %add79
David Blaikiea79ac142015-02-27 21:17:42 +0000470 %tmp25 = load float, float addrspace(3)* %arrayidx80, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000471 %sum.0 = fadd float %tmp16, %tmp17
472 %sum.1 = fadd float %sum.0, %tmp18
473 %sum.2 = fadd float %sum.1, %tmp19
474 %sum.3 = fadd float %sum.2, %tmp20
475 %sum.4 = fadd float %sum.3, %tmp21
476 %sum.5 = fadd float %sum.4, %tmp22
477 %sum.6 = fadd float %sum.5, %tmp23
478 %sum.7 = fadd float %sum.6, %tmp24
479 %sum.8 = fadd float %sum.7, %tmp25
480 store float %sum.8, float addrspace(1)* %C, align 4
481 ret void
482}
483
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000484define amdgpu_kernel void @misaligned_read2_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(3)* %in) #0 {
David Blaikiea79ac142015-02-27 21:17:42 +0000485 %load = load <2 x i32>, <2 x i32> addrspace(3)* %in, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000486 store <2 x i32> %load, <2 x i32> addrspace(1)* %out, align 8
487 ret void
488}
489
Matt Arsenault3dbeefa2017-03-21 21:39:51 +0000490define amdgpu_kernel void @misaligned_read2_i64(i64 addrspace(1)* %out, i64 addrspace(3)* %in) #0 {
David Blaikiea79ac142015-02-27 21:17:42 +0000491 %load = load i64, i64 addrspace(3)* %in, align 4
Matt Arsenault41033282014-10-10 22:01:59 +0000492 store i64 %load, i64 addrspace(1)* %out, align 8
493 ret void
494}
495
Alexander Timofeevf867a402016-11-03 14:37:13 +0000496; SI-LABEL: ds_read_diff_base_interleaving
497; SI-NOT: ds_read_b32
498define amdgpu_kernel void @ds_read_diff_base_interleaving(
499 float addrspace(1)* nocapture %arg,
500 [4 x [4 x float]] addrspace(3)* %arg1,
501 [4 x [4 x float]] addrspace(3)* %arg2,
502 [4 x [4 x float]] addrspace(3)* %arg3,
503 [4 x [4 x float]] addrspace(3)* %arg4) #1 {
504bb:
505 %tmp = getelementptr float, float addrspace(1)* %arg, i64 10
506 %tmp5 = tail call i32 @llvm.amdgcn.workitem.id.x() #2
507 %tmp6 = tail call i32 @llvm.amdgcn.workitem.id.y() #2
508 %tmp7 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg1, i32 0, i32 %tmp6, i32 0
509 %tmp8 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg2, i32 0, i32 0, i32 %tmp5
510 %tmp9 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg3, i32 0, i32 %tmp6, i32 0
511 %tmp10 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg4, i32 0, i32 0, i32 %tmp5
512 %tmp11 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg1, i32 0, i32 %tmp6, i32 1
513 %tmp12 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg2, i32 0, i32 1, i32 %tmp5
514 %tmp13 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg3, i32 0, i32 %tmp6, i32 1
515 %tmp14 = getelementptr [4 x [4 x float]], [4 x [4 x float]] addrspace(3)* %arg4, i32 0, i32 1, i32 %tmp5
516 %tmp15 = load float, float addrspace(3)* %tmp7
517 %tmp16 = load float, float addrspace(3)* %tmp8
518 %tmp17 = fmul float %tmp15, %tmp16
519 %tmp18 = fadd float 2.000000e+00, %tmp17
520 %tmp19 = load float, float addrspace(3)* %tmp9
521 %tmp20 = load float, float addrspace(3)* %tmp10
522 %tmp21 = fmul float %tmp19, %tmp20
523 %tmp22 = fsub float %tmp18, %tmp21
524 %tmp23 = load float, float addrspace(3)* %tmp11
525 %tmp24 = load float, float addrspace(3)* %tmp12
526 %tmp25 = fmul float %tmp23, %tmp24
527 %tmp26 = fsub float %tmp22, %tmp25
528 %tmp27 = load float, float addrspace(3)* %tmp13
529 %tmp28 = load float, float addrspace(3)* %tmp14
530 %tmp29 = fmul float %tmp27, %tmp28
531 %tmp30 = fsub float %tmp26, %tmp29
532 store float %tmp30, float addrspace(1)* %tmp
533 ret void
534}
535
Matt Arsenault41033282014-10-10 22:01:59 +0000536; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000537declare i32 @llvm.amdgcn.workgroup.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000538
539; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000540declare i32 @llvm.amdgcn.workgroup.id.y() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000541
542; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000543declare i32 @llvm.amdgcn.workitem.id.x() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000544
545; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000546declare i32 @llvm.amdgcn.workitem.id.y() #1
Matt Arsenault41033282014-10-10 22:01:59 +0000547
Matt Arsenault2aed6ca2015-12-19 01:46:41 +0000548; Function Attrs: convergent nounwind
Matt Arsenault9c47dd52016-02-11 06:02:01 +0000549declare void @llvm.amdgcn.s.barrier() #2
Matt Arsenault41033282014-10-10 22:01:59 +0000550
Matt Arsenault45f82162016-07-11 23:35:48 +0000551attributes #0 = { nounwind }
Matt Arsenault41033282014-10-10 22:01:59 +0000552attributes #1 = { nounwind readnone }
Matt Arsenault2aed6ca2015-12-19 01:46:41 +0000553attributes #2 = { convergent nounwind }