1; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
3; GCN-LABEL: {{^}}const_load_no_shrink_dword_to_unaligned_byte:
4; GCN: s_load_dword s{{[0-9]+}}
5; GCN: s_load_dword [[LD:s[0-9]+]],
6; GCN: s_bfe_i32 s{{[0-9]+}}, [[LD]], 0x10013
7define amdgpu_kernel void @const_load_no_shrink_dword_to_unaligned_byte(i32 addrspace(1)* %out, i32 addrspace(4)* %in, i32 %x) {
8  %ptr = getelementptr i32, i32 addrspace(4)* %in, i32 %x
9  %load = load i32, i32 addrspace(4)* %ptr, align 4
10  %and = and i32 %load, 524288
11  %cmp = icmp eq i32 %and, 0
12  %sel = select i1 %cmp, i32 0, i32 -1
13  store i32 %sel, i32 addrspace(1)* %out
14  ret void
15}
16
17; GCN-LABEL: const_load_no_shrink_dword_to_aligned_byte:
18; GCN: s_load_dword s{{[0-9]+}}
19; GCN: s_load_dword [[LD:s[0-9]+]],
20; GCN: s_bfe_i32 s{{[0-9]+}}, [[LD]], 0x10003
21define amdgpu_kernel void @const_load_no_shrink_dword_to_aligned_byte(i32 addrspace(1)* %out, i32 addrspace(4)* %in, i32 %x) {
22  %ptr = getelementptr i32, i32 addrspace(4)* %in, i32 %x
23  %load = load i32, i32 addrspace(4)* %ptr, align 4
24  %and = and i32 %load, 8
25  %cmp = icmp eq i32 %and, 0
26  %sel = select i1 %cmp, i32 0, i32 -1
27  store i32 %sel, i32 addrspace(1)* %out
28  ret void
29}
30
31; GCN-LABEL: global_load_no_shrink_dword_to_unaligned_byte:
32; GCN: s_load_dword s{{[0-9]+}}
33; GCN: s_load_dword [[LD:s[0-9]+]],
34; GCN: s_bfe_i32 s{{[0-9]+}}, [[LD]], 0x10013
35define amdgpu_kernel void @global_load_no_shrink_dword_to_unaligned_byte(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %in, i32 %x) {
36  %ptr = getelementptr i32, i32 addrspace(1)* %in, i32 %x
37  %load = load i32, i32 addrspace(1)* %ptr, align 4
38  %and = and i32 %load, 524288
39  %cmp = icmp eq i32 %and, 0
40  %sel = select i1 %cmp, i32 0, i32 -1
41  store i32 %sel, i32 addrspace(1)* %out
42  ret void
43}
44
45; GCN-LABEL: global_load_no_shrink_dword_to_aligned_byte:
46; GCN: s_load_dword s{{[0-9]+}}
47; GCN: s_load_dword [[LD:s[0-9]+]],
48; GCN: s_bfe_i32 s{{[0-9]+}}, [[LD]], 0x10003
49define amdgpu_kernel void @global_load_no_shrink_dword_to_aligned_byte(i32 addrspace(1)* %out, i32 addrspace(1)* %in, i32 %x) {
50  %ptr = getelementptr i32, i32 addrspace(1)* %in, i32 %x
51  %load = load i32, i32 addrspace(1)* %ptr, align 4
52  %and = and i32 %load, 8
53  %cmp = icmp eq i32 %and, 0
54  %sel = select i1 %cmp, i32 0, i32 -1
55  store i32 %sel, i32 addrspace(1)* %out
56  ret void
57}
58
59; GCN-LABEL: const_load_shrink_dword_to_unaligned_byte:
60; GCN: global_load_ushort
61define amdgpu_kernel void @const_load_shrink_dword_to_unaligned_byte(i32 addrspace(1)* %out, i32 addrspace(4)* %in, i32 %x) {
62  %ptr = getelementptr i32, i32 addrspace(4)* %in, i32 %x
63  %load = load i32, i32 addrspace(4)* %ptr, align 2
64  %and = and i32 %load, 524288
65  %cmp = icmp eq i32 %and, 0
66  %sel = select i1 %cmp, i32 0, i32 -1
67  store i32 %sel, i32 addrspace(1)* %out
68  ret void
69}
70