1; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa %s | FileCheck -check-prefixes=GCN,CI %s
2; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa -mcpu=fiji %s | FileCheck -check-prefixes=GCN,GFX89 %s
3; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 %s | FileCheck -check-prefixes=GCN,GFX89 %s
4; RUN: opt -cost-model -cost-kind=code-size -analyze -mtriple=amdgcn-unknown-amdhsa %s | FileCheck -check-prefixes=GCN,CI %s
5; RUN: opt -cost-model -cost-kind=code-size -analyze -mtriple=amdgcn-unknown-amdhsa -mcpu=fiji %s | FileCheck -check-prefixes=GCN,GFX89 %s
6; RUN: opt -cost-model -cost-kind=code-size -analyze -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx900 %s | FileCheck -check-prefixes=GCN,GFX89 %s
7
8; GCN-LABEL: 'insertelement_v2i32'
9; GCN: estimated cost of 0 for {{.*}} insertelement <2 x i32>
10define amdgpu_kernel void @insertelement_v2i32(<2 x i32> addrspace(1)* %out, <2 x i32> addrspace(1)* %vaddr) {
11  %vec = load <2 x i32>, <2 x i32> addrspace(1)* %vaddr
12  %insert = insertelement <2 x i32> %vec, i32 123, i32 1
13  store <2 x i32> %insert, <2 x i32> addrspace(1)* %out
14  ret void
15}
16
17; GCN-LABEL: 'insertelement_v2i64'
18; GCN: estimated cost of 0 for {{.*}} insertelement <2 x i64>
19define amdgpu_kernel void @insertelement_v2i64(<2 x i64> addrspace(1)* %out, <2 x i64> addrspace(1)* %vaddr) {
20  %vec = load <2 x i64>, <2 x i64> addrspace(1)* %vaddr
21  %insert = insertelement <2 x i64> %vec, i64 123, i64 1
22  store <2 x i64> %insert, <2 x i64> addrspace(1)* %out
23  ret void
24}
25
26; GCN-LABEL: 'insertelement_0_v2i16'
27; CI: estimated cost of 1 for {{.*}} insertelement <2 x i16>
28; GFX89: estimated cost of 0 for {{.*}} insertelement <2 x i16>
29define amdgpu_kernel void @insertelement_0_v2i16(<2 x i16> addrspace(1)* %out, <2 x i16> addrspace(1)* %vaddr) {
30  %vec = load <2 x i16>, <2 x i16> addrspace(1)* %vaddr
31  %insert = insertelement <2 x i16> %vec, i16 123, i16 0
32  store <2 x i16> %insert, <2 x i16> addrspace(1)* %out
33  ret void
34}
35
36; GCN-LABEL: 'insertelement_1_v2i16'
37; GCN: estimated cost of 1 for {{.*}} insertelement <2 x i16>
38define amdgpu_kernel void @insertelement_1_v2i16(<2 x i16> addrspace(1)* %out, <2 x i16> addrspace(1)* %vaddr) {
39  %vec = load <2 x i16>, <2 x i16> addrspace(1)* %vaddr
40  %insert = insertelement <2 x i16> %vec, i16 123, i16 1
41  store <2 x i16> %insert, <2 x i16> addrspace(1)* %out
42  ret void
43}
44
45; GCN-LABEL: 'insertelement_1_v2i8'
46; GCN: estimated cost of 1 for {{.*}} insertelement <2 x i8>
47define amdgpu_kernel void @insertelement_1_v2i8(<2 x i8> addrspace(1)* %out, <2 x i8> addrspace(1)* %vaddr) {
48  %vec = load <2 x i8>, <2 x i8> addrspace(1)* %vaddr
49  %insert = insertelement <2 x i8> %vec, i8 123, i8 1
50  store <2 x i8> %insert, <2 x i8> addrspace(1)* %out
51  ret void
52}
53