1; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck %s
2
3; CHECK: 'extractelement_v2i32'
4; CHECK: estimated cost of 0 for {{.*}} extractelement <2 x i32>
5define void @extractelement_v2i32(i32 addrspace(1)* %out, <2 x i32> addrspace(1)* %vaddr) {
6  %vec = load <2 x i32>, <2 x i32> addrspace(1)* %vaddr
7  %elt = extractelement <2 x i32> %vec, i32 1
8  store i32 %elt, i32 addrspace(1)* %out
9  ret void
10}
11
12; CHECK: 'extractelement_v2f32'
13; CHECK: estimated cost of 0 for {{.*}} extractelement <2 x float>
14define void @extractelement_v2f32(float addrspace(1)* %out, <2 x float> addrspace(1)* %vaddr) {
15  %vec = load <2 x float>, <2 x float> addrspace(1)* %vaddr
16  %elt = extractelement <2 x float> %vec, i32 1
17  store float %elt, float addrspace(1)* %out
18  ret void
19}
20
21; CHECK: 'extractelement_v3i32'
22; CHECK: estimated cost of 0 for {{.*}} extractelement <3 x i32>
23define void @extractelement_v3i32(i32 addrspace(1)* %out, <3 x i32> addrspace(1)* %vaddr) {
24  %vec = load <3 x i32>, <3 x i32> addrspace(1)* %vaddr
25  %elt = extractelement <3 x i32> %vec, i32 1
26  store i32 %elt, i32 addrspace(1)* %out
27  ret void
28}
29
30; CHECK: 'extractelement_v4i32'
31; CHECK: estimated cost of 0 for {{.*}} extractelement <4 x i32>
32define void @extractelement_v4i32(i32 addrspace(1)* %out, <4 x i32> addrspace(1)* %vaddr) {
33  %vec = load <4 x i32>, <4 x i32> addrspace(1)* %vaddr
34  %elt = extractelement <4 x i32> %vec, i32 1
35  store i32 %elt, i32 addrspace(1)* %out
36  ret void
37}
38
39; CHECK: 'extractelement_v8i32'
40; CHECK: estimated cost of 0 for {{.*}} extractelement <8 x i32>
41define void @extractelement_v8i32(i32 addrspace(1)* %out, <8 x i32> addrspace(1)* %vaddr) {
42  %vec = load <8 x i32>, <8 x i32> addrspace(1)* %vaddr
43  %elt = extractelement <8 x i32> %vec, i32 1
44  store i32 %elt, i32 addrspace(1)* %out
45  ret void
46}
47
48; FIXME: Should be non-0
49; CHECK: 'extractelement_v8i32_dynindex'
50; CHECK: estimated cost of 2 for {{.*}} extractelement <8 x i32>
51define void @extractelement_v8i32_dynindex(i32 addrspace(1)* %out, <8 x i32> addrspace(1)* %vaddr, i32 %idx) {
52  %vec = load <8 x i32>, <8 x i32> addrspace(1)* %vaddr
53  %elt = extractelement <8 x i32> %vec, i32 %idx
54  store i32 %elt, i32 addrspace(1)* %out
55  ret void
56}
57
58; CHECK: 'extractelement_v2i64'
59; CHECK: estimated cost of 0 for {{.*}} extractelement <2 x i64>
60define void @extractelement_v2i64(i64 addrspace(1)* %out, <2 x i64> addrspace(1)* %vaddr) {
61  %vec = load <2 x i64>, <2 x i64> addrspace(1)* %vaddr
62  %elt = extractelement <2 x i64> %vec, i64 1
63  store i64 %elt, i64 addrspace(1)* %out
64  ret void
65}
66
67; CHECK: 'extractelement_v3i64'
68; CHECK: estimated cost of 0 for {{.*}} extractelement <3 x i64>
69define void @extractelement_v3i64(i64 addrspace(1)* %out, <3 x i64> addrspace(1)* %vaddr) {
70  %vec = load <3 x i64>, <3 x i64> addrspace(1)* %vaddr
71  %elt = extractelement <3 x i64> %vec, i64 1
72  store i64 %elt, i64 addrspace(1)* %out
73  ret void
74}
75
76; CHECK: 'extractelement_v4i64'
77; CHECK: estimated cost of 0 for {{.*}} extractelement <4 x i64>
78define void @extractelement_v4i64(i64 addrspace(1)* %out, <4 x i64> addrspace(1)* %vaddr) {
79  %vec = load <4 x i64>, <4 x i64> addrspace(1)* %vaddr
80  %elt = extractelement <4 x i64> %vec, i64 1
81  store i64 %elt, i64 addrspace(1)* %out
82  ret void
83}
84
85; CHECK: 'extractelement_v8i64'
86; CHECK: estimated cost of 0 for {{.*}} extractelement <8 x i64>
87define void @extractelement_v8i64(i64 addrspace(1)* %out, <8 x i64> addrspace(1)* %vaddr) {
88  %vec = load <8 x i64>, <8 x i64> addrspace(1)* %vaddr
89  %elt = extractelement <8 x i64> %vec, i64 1
90  store i64 %elt, i64 addrspace(1)* %out
91  ret void
92}
93
94; CHECK: 'extractelement_v4i8'
95; CHECK: estimated cost of 0 for {{.*}} extractelement <4 x i8>
96define void @extractelement_v4i8(i8 addrspace(1)* %out, <4 x i8> addrspace(1)* %vaddr) {
97  %vec = load <4 x i8>, <4 x i8> addrspace(1)* %vaddr
98  %elt = extractelement <4 x i8> %vec, i8 1
99  store i8 %elt, i8 addrspace(1)* %out
100  ret void
101}
102
103; CHECK: 'extractelement_v2i16'
104; CHECK: estimated cost of 0 for {{.*}} extractelement <2 x i16>
105define void @extractelement_v2i16(i16 addrspace(1)* %out, <2 x i16> addrspace(1)* %vaddr) {
106  %vec = load <2 x i16>, <2 x i16> addrspace(1)* %vaddr
107  %elt = extractelement <2 x i16> %vec, i16 1
108  store i16 %elt, i16 addrspace(1)* %out
109  ret void
110}
111