blob: ea7357d78a80aaaecca00432b9dd3f9fdd5e8a60 [file] [log] [blame]
Matt Arsenault8d1052f2016-04-21 18:03:06 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
3; Extract the high bit of the 1st quarter
4; GCN-LABEL: {{^}}v_uextract_bit_31_i128:
5; GCN: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
6
Tom Stellardcb6ba622016-04-30 00:23:06 +00007; GCN: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
Matt Arsenault2b957b52016-05-02 20:07:26 +00008; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +00009; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
10
Matt Arsenault2b957b52016-05-02 20:07:26 +000011; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[ZERO0]]:[[ZERO1]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000012; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[SHIFT]]:[[ZERO0]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
13; GCN: s_endpgm
14define void @v_uextract_bit_31_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
15 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
16 %in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
17 %out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
18 %ld.64 = load i128, i128 addrspace(1)* %in.gep
19 %srl = lshr i128 %ld.64, 31
20 %bit = and i128 %srl, 1
21 store i128 %bit, i128 addrspace(1)* %out.gep
22 ret void
23}
24
25; Extract the high bit of the 2nd quarter
26; GCN-LABEL: {{^}}v_uextract_bit_63_i128:
27; GCN: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4{{$}}
28
Tom Stellardcb6ba622016-04-30 00:23:06 +000029; GCN: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
Matt Arsenault2b957b52016-05-02 20:07:26 +000030; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000031; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
32
Matt Arsenault2b957b52016-05-02 20:07:26 +000033; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[ZERO0]]:[[ZERO1]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000034; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[SHIFT]]:[[ZERO0]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
35; GCN: s_endpgm
36define void @v_uextract_bit_63_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
37 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
38 %in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
39 %out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
40 %ld.64 = load i128, i128 addrspace(1)* %in.gep
41 %srl = lshr i128 %ld.64, 63
42 %bit = and i128 %srl, 1
43 store i128 %bit, i128 addrspace(1)* %out.gep
44 ret void
45}
46
47; Extract the high bit of the 3rd quarter
48; GCN-LABEL: {{^}}v_uextract_bit_95_i128:
49; GCN: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
50
Tom Stellardcb6ba622016-04-30 00:23:06 +000051; GCN: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
Matt Arsenault2b957b52016-05-02 20:07:26 +000052; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000053; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
54
Matt Arsenault2b957b52016-05-02 20:07:26 +000055; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[ZERO0]]:[[ZERO1]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000056; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[SHIFT]]:[[ZERO0]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
57; GCN: s_endpgm
58define void @v_uextract_bit_95_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
59 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
60 %in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
61 %out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
62 %ld.64 = load i128, i128 addrspace(1)* %in.gep
63 %srl = lshr i128 %ld.64, 95
64 %bit = and i128 %srl, 1
65 store i128 %bit, i128 addrspace(1)* %out.gep
66 ret void
67}
68
69; Extract the high bit of the 4th quarter
70; GCN-LABEL: {{^}}v_uextract_bit_127_i128:
71; GCN: buffer_load_dword [[VAL:v[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:12{{$}}
72
Tom Stellardcb6ba622016-04-30 00:23:06 +000073; GCN: v_mov_b32_e32 v[[ZERO0:[0-9]+]], 0{{$}}
Matt Arsenault2b957b52016-05-02 20:07:26 +000074; GCN: v_mov_b32_e32 v[[ZERO1:[0-9]+]], v[[ZERO0]]{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000075; GCN-DAG: v_lshrrev_b32_e32 v[[SHIFT:[0-9]+]], 31, [[VAL]]
76
Matt Arsenault2b957b52016-05-02 20:07:26 +000077; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[ZERO0]]:[[ZERO1]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
Matt Arsenault8d1052f2016-04-21 18:03:06 +000078; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[SHIFT]]:[[ZERO0]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
79; GCN: s_endpgm
80define void @v_uextract_bit_127_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
81 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
82 %in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
83 %out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
84 %ld.64 = load i128, i128 addrspace(1)* %in.gep
85 %srl = lshr i128 %ld.64, 127
86 %bit = and i128 %srl, 1
87 store i128 %bit, i128 addrspace(1)* %out.gep
88 ret void
89}
90
91; Spans more than 2 dword boundaries
92; GCN-LABEL: {{^}}v_uextract_bit_34_100_i128:
93; GCN: buffer_load_dwordx2 v{{\[}}[[VAL2:[0-9]+]]:[[VAL3:[0-9]+]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
94; GCN: buffer_load_dword v[[VAL1:[0-9]+]], v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:4{{$}}
95
96; GCN-DAG: v_lshl_b64 v{{\[}}[[SHLLO:[0-9]+]]:[[SHLHI:[0-9]+]]{{\]}}, v{{\[}}[[VAL2]]:[[VAL3]]{{\]}}, 30
97; GCN-DAG: v_lshrrev_b32_e32 v[[ELT1PART:[0-9]+]], 2, v[[VAL1]]
98; GCN-DAG: v_bfe_u32 v[[ELT2PART:[0-9]+]], v[[VAL3]], 2, 2{{$}}
99; GCN-DAG: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
100; GCN-DAG: v_or_b32_e32 v[[OR0:[0-9]+]], v[[SHLLO]], v[[ELT1PART]]
101; GCN-DAG: v_or_b32_e32 v[[OR1:[0-9]+]], 0, v[[SHLHI]]{{$}}
102
103; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[ELT2PART]]:[[ZERO]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64 offset:8{{$}}
104; GCN-DAG: buffer_store_dwordx2 v{{\[}}[[OR0]]:[[OR1]]{{\]}}, v{{\[[0-9]+:[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0 addr64{{$}}
105; GCN: s_endpgm
106define void @v_uextract_bit_34_100_i128(i128 addrspace(1)* %out, i128 addrspace(1)* %in) #1 {
107 %id.x = tail call i32 @llvm.amdgcn.workitem.id.x()
108 %in.gep = getelementptr i128, i128 addrspace(1)* %in, i32 %id.x
109 %out.gep = getelementptr i128, i128 addrspace(1)* %out, i32 %id.x
110 %ld.64 = load i128, i128 addrspace(1)* %in.gep
111 %srl = lshr i128 %ld.64, 34
112 %bit = and i128 %srl, 73786976294838206463
113 store i128 %bit, i128 addrspace(1)* %out.gep
114 ret void
115}
116
117declare i32 @llvm.amdgcn.workitem.id.x() #0
118
119attributes #0 = { nounwind readnone }
120attributes #1 = { nounwind }