1 ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -infer-address-spaces %s | FileCheck %s
3 ; CHECK-LABEL: @objectsize_group_to_flat_i32(
4 ; CHECK: %val = call i32 @llvm.objectsize.i32.p3i8(i8 addrspace(3)* %group.ptr, i1 true, i1 false, i1 false)
5 define i32 @objectsize_group_to_flat_i32(i8 addrspace(3)* %group.ptr) #0 {
6 %cast = addrspacecast i8 addrspace(3)* %group.ptr to i8*
7 %val = call i32 @llvm.objectsize.i32.p0i8(i8* %cast, i1 true, i1 false, i1 false)
11 ; CHECK-LABEL: @objectsize_global_to_flat_i64(
12 ; CHECK: %val = call i64 @llvm.objectsize.i64.p3i8(i8 addrspace(3)* %global.ptr, i1 true, i1 false, i1 false)
13 define i64 @objectsize_global_to_flat_i64(i8 addrspace(3)* %global.ptr) #0 {
14 %cast = addrspacecast i8 addrspace(3)* %global.ptr to i8*
15 %val = call i64 @llvm.objectsize.i64.p0i8(i8* %cast, i1 true, i1 false, i1 false)
19 ; CHECK-LABEL: @atomicinc_global_to_flat_i32(
20 ; CHECK: call i32 @llvm.amdgcn.atomic.inc.i32.p1i32(i32 addrspace(1)* %global.ptr, i32 %y, i32 0, i32 0, i1 false)
21 define i32 @atomicinc_global_to_flat_i32(i32 addrspace(1)* %global.ptr, i32 %y) #0 {
22 %cast = addrspacecast i32 addrspace(1)* %global.ptr to i32*
23 %ret = call i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* %cast, i32 %y, i32 0, i32 0, i1 false)
27 ; CHECK-LABEL: @atomicinc_group_to_flat_i32(
28 ; CHECK: %ret = call i32 @llvm.amdgcn.atomic.inc.i32.p3i32(i32 addrspace(3)* %group.ptr, i32 %y, i32 0, i32 0, i1 false)
29 define i32 @atomicinc_group_to_flat_i32(i32 addrspace(3)* %group.ptr, i32 %y) #0 {
30 %cast = addrspacecast i32 addrspace(3)* %group.ptr to i32*
31 %ret = call i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* %cast, i32 %y, i32 0, i32 0, i1 false)
35 ; CHECK-LABEL: @atomicinc_global_to_flat_i64(
36 ; CHECK: call i64 @llvm.amdgcn.atomic.inc.i64.p1i64(i64 addrspace(1)* %global.ptr, i64 %y, i32 0, i32 0, i1 false)
37 define i64 @atomicinc_global_to_flat_i64(i64 addrspace(1)* %global.ptr, i64 %y) #0 {
38 %cast = addrspacecast i64 addrspace(1)* %global.ptr to i64*
39 %ret = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 false)
43 ; CHECK-LABEL: @atomicinc_group_to_flat_i64(
44 ; CHECK: call i64 @llvm.amdgcn.atomic.inc.i64.p3i64(i64 addrspace(3)* %group.ptr, i64 %y, i32 0, i32 0, i1 false)
45 define i64 @atomicinc_group_to_flat_i64(i64 addrspace(3)* %group.ptr, i64 %y) #0 {
46 %cast = addrspacecast i64 addrspace(3)* %group.ptr to i64*
47 %ret = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 false)
51 ; CHECK-LABEL: @atomicdec_global_to_flat_i32(
52 ; CHECK: call i32 @llvm.amdgcn.atomic.dec.i32.p1i32(i32 addrspace(1)* %global.ptr, i32 %val, i32 0, i32 0, i1 false)
53 define i32 @atomicdec_global_to_flat_i32(i32 addrspace(1)* %global.ptr, i32 %val) #0 {
54 %cast = addrspacecast i32 addrspace(1)* %global.ptr to i32*
55 %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %cast, i32 %val, i32 0, i32 0, i1 false)
59 ; CHECK-LABEL: @atomicdec_group_to_flat_i32(
60 ; CHECK: %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p3i32(i32 addrspace(3)* %group.ptr, i32 %val, i32 0, i32 0, i1 false)
61 define i32 @atomicdec_group_to_flat_i32(i32 addrspace(3)* %group.ptr, i32 %val) #0 {
62 %cast = addrspacecast i32 addrspace(3)* %group.ptr to i32*
63 %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %cast, i32 %val, i32 0, i32 0, i1 false)
67 ; CHECK-LABEL: @atomicdec_global_to_flat_i64(
68 ; CHECK: call i64 @llvm.amdgcn.atomic.dec.i64.p1i64(i64 addrspace(1)* %global.ptr, i64 %y, i32 0, i32 0, i1 false)
69 define i64 @atomicdec_global_to_flat_i64(i64 addrspace(1)* %global.ptr, i64 %y) #0 {
70 %cast = addrspacecast i64 addrspace(1)* %global.ptr to i64*
71 %ret = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 false)
75 ; CHECK-LABEL: @atomicdec_group_to_flat_i64(
76 ; CHECK: call i64 @llvm.amdgcn.atomic.dec.i64.p3i64(i64 addrspace(3)* %group.ptr, i64 %y, i32 0, i32 0, i1 false
77 define i64 @atomicdec_group_to_flat_i64(i64 addrspace(3)* %group.ptr, i64 %y) #0 {
78 %cast = addrspacecast i64 addrspace(3)* %group.ptr to i64*
79 %ret = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 false)
83 ; CHECK-LABEL: @volatile_atomicinc_group_to_flat_i64(
84 ; CHECK-NEXT: %cast = addrspacecast i64 addrspace(3)* %group.ptr to i64*
85 ; CHECK-NEXT: %ret = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 true)
86 define i64 @volatile_atomicinc_group_to_flat_i64(i64 addrspace(3)* %group.ptr, i64 %y) #0 {
87 %cast = addrspacecast i64 addrspace(3)* %group.ptr to i64*
88 %ret = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 true)
92 ; CHECK-LABEL: @volatile_atomicdec_global_to_flat_i32(
93 ; CHECK-NEXT: %cast = addrspacecast i32 addrspace(1)* %global.ptr to i32*
94 ; CHECK-NEXT: %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %cast, i32 %val, i32 0, i32 0, i1 true)
95 define i32 @volatile_atomicdec_global_to_flat_i32(i32 addrspace(1)* %global.ptr, i32 %val) #0 {
96 %cast = addrspacecast i32 addrspace(1)* %global.ptr to i32*
97 %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %cast, i32 %val, i32 0, i32 0, i1 true)
101 ; CHECK-LABEL: @volatile_atomicdec_group_to_flat_i32(
102 ; CHECK-NEXT: %cast = addrspacecast i32 addrspace(3)* %group.ptr to i32*
103 ; CHECK-NEXT: %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %cast, i32 %val, i32 0, i32 0, i1 true)
104 define i32 @volatile_atomicdec_group_to_flat_i32(i32 addrspace(3)* %group.ptr, i32 %val) #0 {
105 %cast = addrspacecast i32 addrspace(3)* %group.ptr to i32*
106 %ret = call i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* %cast, i32 %val, i32 0, i32 0, i1 true)
110 ; CHECK-LABEL: @volatile_atomicdec_global_to_flat_i64(
111 ; CHECK-NEXT: %cast = addrspacecast i64 addrspace(1)* %global.ptr to i64*
112 ; CHECK-NEXT: %ret = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 true)
113 define i64 @volatile_atomicdec_global_to_flat_i64(i64 addrspace(1)* %global.ptr, i64 %y) #0 {
114 %cast = addrspacecast i64 addrspace(1)* %global.ptr to i64*
115 %ret = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 true)
119 ; CHECK-LABEL: @volatile_atomicdec_group_to_flat_i64(
120 ; CHECK-NEXT: %cast = addrspacecast i64 addrspace(3)* %group.ptr to i64*
121 ; CHECK-NEXT: %ret = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 true)
122 define i64 @volatile_atomicdec_group_to_flat_i64(i64 addrspace(3)* %group.ptr, i64 %y) #0 {
123 %cast = addrspacecast i64 addrspace(3)* %group.ptr to i64*
124 %ret = call i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* %cast, i64 %y, i32 0, i32 0, i1 true)
128 declare i32 @llvm.objectsize.i32.p0i8(i8*, i1, i1, i1) #1
129 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1, i1) #1
130 declare i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* nocapture, i32, i32, i32, i1) #2
131 declare i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* nocapture, i64, i32, i32, i1) #2
132 declare i32 @llvm.amdgcn.atomic.dec.i32.p0i32(i32* nocapture, i32, i32, i32, i1) #2
133 declare i64 @llvm.amdgcn.atomic.dec.i64.p0i64(i64* nocapture, i64, i32, i32, i1) #2
135 attributes #0 = { nounwind }
136 attributes #1 = { nounwind readnone }
137 attributes #2 = { nounwind argmemonly }