1; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
4
5; FUNC-LABEL: {{^}}anyext_load_i8:
6; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+.[XYZW]]],
7; EG: VTX_READ_32 [[VAL]]
8
9define void @anyext_load_i8(i8 addrspace(1)* nocapture noalias %out, i8 addrspace(1)* nocapture noalias %src) nounwind {
10  %cast = bitcast i8 addrspace(1)* %src to i32 addrspace(1)*
11  %load = load i32, i32 addrspace(1)* %cast, align 1
12  %x = bitcast i32 %load to <4 x i8>
13  %castOut = bitcast i8 addrspace(1)* %out to <4 x i8> addrspace(1)*
14  store <4 x i8> %x, <4 x i8> addrspace(1)* %castOut, align 1
15  ret void
16}
17
18; FUNC-LABEL: {{^}}anyext_load_i16:
19; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+.[XYZW]]],
20; EG: VTX_READ_32 [[VAL]]
21
22define void @anyext_load_i16(i16 addrspace(1)* nocapture noalias %out, i16 addrspace(1)* nocapture noalias %src) nounwind {
23  %cast = bitcast i16 addrspace(1)* %src to i32 addrspace(1)*
24  %load = load i32, i32 addrspace(1)* %cast, align 1
25  %x = bitcast i32 %load to <2 x i16>
26  %castOut = bitcast i16 addrspace(1)* %out to <2 x i16> addrspace(1)*
27  store <2 x i16> %x, <2 x i16> addrspace(1)* %castOut, align 1
28  ret void
29}
30
31; FUNC-LABEL: {{^}}anyext_load_lds_i8:
32; EG: LDS_READ_RET {{.*}}, [[VAL:T[0-9]+.[XYZW]]]
33; EG: LDS_WRITE * [[VAL]]
34define void @anyext_load_lds_i8(i8 addrspace(3)* nocapture noalias %out, i8 addrspace(3)* nocapture noalias %src) nounwind {
35  %cast = bitcast i8 addrspace(3)* %src to i32 addrspace(3)*
36  %load = load i32, i32 addrspace(3)* %cast, align 1
37  %x = bitcast i32 %load to <4 x i8>
38  %castOut = bitcast i8 addrspace(3)* %out to <4 x i8> addrspace(3)*
39  store <4 x i8> %x, <4 x i8> addrspace(3)* %castOut, align 1
40  ret void
41}
42
43; FUNC-LABEL: {{^}}anyext_load_lds_i16:
44; EG: LDS_READ_RET {{.*}}, [[VAL:T[0-9]+.[XYZW]]]
45; EG: LDS_WRITE * [[VAL]]
46define void @anyext_load_lds_i16(i16 addrspace(3)* nocapture noalias %out, i16 addrspace(3)* nocapture noalias %src) nounwind {
47  %cast = bitcast i16 addrspace(3)* %src to i32 addrspace(3)*
48  %load = load i32, i32 addrspace(3)* %cast, align 1
49  %x = bitcast i32 %load to <2 x i16>
50  %castOut = bitcast i16 addrspace(3)* %out to <2 x i16> addrspace(3)*
51  store <2 x i16> %x, <2 x i16> addrspace(3)* %castOut, align 1
52  ret void
53}
54