1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI-NOHSA -check-prefix=FUNC %s
2; RUN: llc -mtriple=amdgcn-amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=FUNC -check-prefix=CI-HSA -check-prefix=SI %s
3; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=SI-NOHSA -check-prefix=FUNC %s
4; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
5
6; FIXME: This seems to not ever actually become an extload
7; FUNC-LABEL: {{^}}global_anyext_load_i8:
8; GCN: buffer_load_dword v{{[0-9]+}}
9; GCN: buffer_store_dword v{{[0-9]+}}
10
11; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+.[XYZW]]],
12; EG: VTX_READ_32 [[VAL]]
13define amdgpu_kernel void @global_anyext_load_i8(i8 addrspace(1)* nocapture noalias %out, i8 addrspace(1)* nocapture noalias %src) nounwind {
14  %cast = bitcast i8 addrspace(1)* %src to i32 addrspace(1)*
15  %load = load i32, i32 addrspace(1)* %cast
16  %x = bitcast i32 %load to <4 x i8>
17  %castOut = bitcast i8 addrspace(1)* %out to <4 x i8> addrspace(1)*
18  store <4 x i8> %x, <4 x i8> addrspace(1)* %castOut
19  ret void
20}
21
22; FUNC-LABEL: {{^}}global_anyext_load_i16:
23; GCN: buffer_load_dword v{{[0-9]+}}
24; GCN: buffer_store_dword v{{[0-9]+}}
25
26; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+.[XYZW]]],
27; EG: VTX_READ_32 [[VAL]]
28define amdgpu_kernel void @global_anyext_load_i16(i16 addrspace(1)* nocapture noalias %out, i16 addrspace(1)* nocapture noalias %src) nounwind {
29  %cast = bitcast i16 addrspace(1)* %src to i32 addrspace(1)*
30  %load = load i32, i32 addrspace(1)* %cast
31  %x = bitcast i32 %load to <2 x i16>
32  %castOut = bitcast i16 addrspace(1)* %out to <2 x i16> addrspace(1)*
33  store <2 x i16> %x, <2 x i16> addrspace(1)* %castOut
34  ret void
35}
36
37; FUNC-LABEL: {{^}}local_anyext_load_i8:
38; GCN: ds_read_b32 v{{[0-9]+}}
39; GCN: ds_write_b32 v{{[0-9]+}}
40
41; EG: LDS_READ_RET {{.*}}, [[VAL:T[0-9]+.[XYZW]]]
42; EG: LDS_WRITE * [[VAL]]
43define amdgpu_kernel void @local_anyext_load_i8(i8 addrspace(3)* nocapture noalias %out, i8 addrspace(3)* nocapture noalias %src) nounwind {
44  %cast = bitcast i8 addrspace(3)* %src to i32 addrspace(3)*
45  %load = load i32, i32 addrspace(3)* %cast
46  %x = bitcast i32 %load to <4 x i8>
47  %castOut = bitcast i8 addrspace(3)* %out to <4 x i8> addrspace(3)*
48  store <4 x i8> %x, <4 x i8> addrspace(3)* %castOut
49  ret void
50}
51
52; FUNC-LABEL: {{^}}local_anyext_load_i16:
53; GCN: ds_read_b32 v{{[0-9]+}}
54; GCN: ds_write_b32 v{{[0-9]+}}
55
56; EG: LDS_READ_RET {{.*}}, [[VAL:T[0-9]+.[XYZW]]]
57; EG: LDS_WRITE * [[VAL]]
58define amdgpu_kernel void @local_anyext_load_i16(i16 addrspace(3)* nocapture noalias %out, i16 addrspace(3)* nocapture noalias %src) nounwind {
59  %cast = bitcast i16 addrspace(3)* %src to i32 addrspace(3)*
60  %load = load i32, i32 addrspace(3)* %cast
61  %x = bitcast i32 %load to <2 x i16>
62  %castOut = bitcast i16 addrspace(3)* %out to <2 x i16> addrspace(3)*
63  store <2 x i16> %x, <2 x i16> addrspace(3)* %castOut
64  ret void
65}
66