1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3
4; How the replacement of i64 stores with v2i32 stores resulted in
5; breaking other users of the bitcast if they already existed
6
7; GCN-LABEL: {{^}}extract_vector_elt_select_error:
8; GCN: buffer_store_dword
9; GCN: buffer_store_dword
10; GCN: buffer_store_dwordx2
11define void @extract_vector_elt_select_error(i32 addrspace(1)* %out, i64 addrspace(1)* %in, i64 %val) #0 {
12  %vec = bitcast i64 %val to <2 x i32>
13  %elt0 = extractelement <2 x i32> %vec, i32 0
14  %elt1 = extractelement <2 x i32> %vec, i32 1
15
16  store volatile i32 %elt0, i32 addrspace(1)* %out
17  store volatile i32 %elt1, i32 addrspace(1)* %out
18  store volatile i64 %val, i64 addrspace(1)* %in
19  ret void
20}
21
22; GCN-LABEL: {{^}}extract_vector_elt_v2i64:
23define void @extract_vector_elt_v2i64(i64 addrspace(1)* %out, <2 x i64> %foo) #0 {
24  %p0 = extractelement <2 x i64> %foo, i32 0
25  %p1 = extractelement <2 x i64> %foo, i32 1
26  %out1 = getelementptr i64, i64 addrspace(1)* %out, i32 1
27  store volatile i64 %p1, i64 addrspace(1)* %out
28  store volatile i64 %p0, i64 addrspace(1)* %out1
29  ret void
30}
31
32; GCN-LABEL: {{^}}dyn_extract_vector_elt_v2i64:
33define void @dyn_extract_vector_elt_v2i64(i64 addrspace(1)* %out, <2 x i64> %foo, i32 %elt) #0 {
34  %dynelt = extractelement <2 x i64> %foo, i32 %elt
35  store volatile i64 %dynelt, i64 addrspace(1)* %out
36  ret void
37}
38
39; GCN-LABEL: {{^}}dyn_extract_vector_elt_v2i64_2:
40define void @dyn_extract_vector_elt_v2i64_2(i64 addrspace(1)* %out, <2 x i64> addrspace(1)* %foo, i32 %elt, <2 x i64> %arst) #0 {
41  %load = load volatile <2 x i64>, <2 x i64> addrspace(1)* %foo
42  %or = or <2 x i64> %load, %arst
43  %dynelt = extractelement <2 x i64> %or, i32 %elt
44  store volatile i64 %dynelt, i64 addrspace(1)* %out
45  ret void
46}
47
48; GCN-LABEL: {{^}}dyn_extract_vector_elt_v3i64:
49define void @dyn_extract_vector_elt_v3i64(i64 addrspace(1)* %out, <3 x i64> %foo, i32 %elt) #0 {
50  %dynelt = extractelement <3 x i64> %foo, i32 %elt
51  store volatile i64 %dynelt, i64 addrspace(1)* %out
52  ret void
53}
54
55; GCN-LABEL: {{^}}dyn_extract_vector_elt_v4i64:
56define void @dyn_extract_vector_elt_v4i64(i64 addrspace(1)* %out, <4 x i64> %foo, i32 %elt) #0 {
57  %dynelt = extractelement <4 x i64> %foo, i32 %elt
58  store volatile i64 %dynelt, i64 addrspace(1)* %out
59  ret void
60}
61
62attributes #0 = { nounwind }
63