1; RUN: opt -cost-model -analyze -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri < %s | FileCheck %s
2
3; CHECK: 'addrspacecast_global_to_flat'
4; CHECK: estimated cost of 0 for {{.*}} addrspacecast i8 addrspace(1)* %ptr to i8*
5define i8* @addrspacecast_global_to_flat(i8 addrspace(1)* %ptr) #0 {
6  %cast = addrspacecast i8 addrspace(1)* %ptr to i8*
7  ret i8* %cast
8}
9
10; CHECK: 'addrspacecast_global_to_flat_v2'
11; CHECK: estimated cost of 0 for {{.*}} addrspacecast <2 x i8 addrspace(1)*> %ptr to <2 x i8*>
12define <2 x i8*> @addrspacecast_global_to_flat_v2(<2 x i8 addrspace(1)*> %ptr) #0 {
13  %cast = addrspacecast <2 x i8 addrspace(1)*> %ptr to <2 x i8*>
14  ret <2 x i8*> %cast
15}
16
17; CHECK: 'addrspacecast_global_to_flat_v32'
18; CHECK: estimated cost of 0 for {{.*}} addrspacecast <32 x i8 addrspace(1)*> %ptr to <32 x i8*>
19define <32 x i8*> @addrspacecast_global_to_flat_v32(<32 x i8 addrspace(1)*> %ptr) #0 {
20  %cast = addrspacecast <32 x i8 addrspace(1)*> %ptr to <32 x i8*>
21  ret <32 x i8*> %cast
22}
23
24; CHECK: 'addrspacecast_local_to_flat'
25; CHECK: estimated cost of 1 for {{.*}} addrspacecast i8 addrspace(3)* %ptr to i8*
26define i8* @addrspacecast_local_to_flat(i8 addrspace(3)* %ptr) #0 {
27  %cast = addrspacecast i8 addrspace(3)* %ptr to i8*
28  ret i8* %cast
29}
30
31; CHECK: 'addrspacecast_local_to_flat_v2'
32; CHECK: estimated cost of 2 for {{.*}} addrspacecast <2 x i8 addrspace(3)*> %ptr to <2 x i8*>
33define <2 x i8*> @addrspacecast_local_to_flat_v2(<2 x i8 addrspace(3)*> %ptr) #0 {
34  %cast = addrspacecast <2 x i8 addrspace(3)*> %ptr to <2 x i8*>
35  ret <2 x i8*> %cast
36}
37
38; CHECK: 'addrspacecast_local_to_flat_v32'
39; CHECK: estimated cost of 32 for {{.*}} addrspacecast <32 x i8 addrspace(3)*> %ptr to <32 x i8*>
40define <32 x i8*> @addrspacecast_local_to_flat_v32(<32 x i8 addrspace(3)*> %ptr) #0 {
41  %cast = addrspacecast <32 x i8 addrspace(3)*> %ptr to <32 x i8*>
42  ret <32 x i8*> %cast
43}
44
45attributes #0 = { nounwind readnone }
46