Skip to content

Commit ee3a6cf

Browse files
committed
AMDGPU: Add tests for atomicrmw handling of new metadata
Add baseline tests which should comprehensively test the new atomic metadata. Test codegen / expansion, and preservation in a few transforms. New metadata defined in #89248
1 parent 9606716 commit ee3a6cf

16 files changed

+18408
-1640
lines changed

llvm/test/CodeGen/AMDGPU/flat_atomics_i32_system.ll

Lines changed: 1744 additions & 417 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/flat_atomics_i64_system.ll

Lines changed: 1875 additions & 393 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/global_atomics_i32_system.ll

Lines changed: 1918 additions & 463 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/global_atomics_i64_system.ll

Lines changed: 1961 additions & 367 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/global_atomics_scan_fadd.ll

Lines changed: 741 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/global_atomics_scan_fmax.ll

Lines changed: 672 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/global_atomics_scan_fmin.ll

Lines changed: 671 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-f32-system.ll

Lines changed: 3717 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-f64-system.ll

Lines changed: 1685 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-i32-system.ll

Lines changed: 828 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-i64-system.ll

Lines changed: 828 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-v2bf16-system.ll

Lines changed: 859 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-v2f16-system.ll

Lines changed: 859 additions & 0 deletions
Large diffs are not rendered by default.

llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomicrmw-integer-ops-0-to-add-0.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ define i32 @test_atomicrmw_xor_0_global_system(ptr addrspace(1) %ptr) {
124124
}
125125

126126

127+
define i32 @test_atomicrmw_or_0_global_system__metadata(ptr addrspace(1) %ptr) {
128+
; CHECK-LABEL: define i32 @test_atomicrmw_or_0_global_system__metadata(
129+
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
130+
; CHECK-NEXT: [[RES:%.*]] = atomicrmw add ptr addrspace(1) [[PTR]], i32 0 seq_cst, align 4, !amdgpu.no.fine.grained.memory [[META0]], !amdgpu.no.remote.memory.access [[META0]]
131+
; CHECK-NEXT: ret i32 [[RES]]
132+
;
133+
%res = atomicrmw or ptr addrspace(1) %ptr, i32 0 seq_cst, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
134+
ret i32 %res
135+
}
136+
127137
!0 = !{}
128138
;.
129139
; CHECK: [[META0]] = !{}

llvm/test/Transforms/InferAddressSpaces/AMDGPU/basic.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,14 @@ entry:
182182
ret void
183183
}
184184

185+
; CHECK-LABEL: @atomicrmw_add_global_to_flat_preserve_amdgpu_md(
186+
; CHECK-NEXT: %ret = atomicrmw add ptr addrspace(1) %global.ptr, i32 %y seq_cst, align 4, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
187+
define i32 @atomicrmw_add_global_to_flat_preserve_amdgpu_md(ptr addrspace(1) %global.ptr, i32 %y) #0 {
188+
%cast = addrspacecast ptr addrspace(1) %global.ptr to ptr
189+
%ret = atomicrmw add ptr %cast, i32 %y seq_cst, align 4, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
190+
ret i32 %ret
191+
}
192+
185193
attributes #0 = { nounwind }
194+
195+
!0 = !{}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2+
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes=inline < %s | FileCheck %s
3+
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes='cgscc(inline)' < %s | FileCheck %s
4+
5+
; Ensure that custom metadata survives inlining
6+
7+
define i32 @atomic_xor(ptr addrspace(1) %ptr, i32 %val) {
8+
; CHECK-LABEL: define i32 @atomic_xor(
9+
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]], i32 [[VAL:%.*]]) {
10+
; CHECK-NEXT: [[RES:%.*]] = atomicrmw xor ptr addrspace(1) [[PTR]], i32 [[VAL]] monotonic, align 4, !amdgpu.no.fine.grained.memory [[META0:![0-9]+]], !amdgpu.no.remote.memory.access [[META0]]
11+
; CHECK-NEXT: ret i32 [[RES]]
12+
;
13+
%res = atomicrmw xor ptr addrspace(1) %ptr, i32 %val monotonic, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
14+
ret i32 %res
15+
}
16+
17+
define i32 @caller(ptr addrspace(1) %ptr, i32 %val) {
18+
; CHECK-LABEL: define i32 @caller(
19+
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]], i32 [[VAL:%.*]]) {
20+
; CHECK-NEXT: [[RES_I:%.*]] = atomicrmw xor ptr addrspace(1) [[PTR]], i32 [[VAL]] monotonic, align 4, !amdgpu.no.fine.grained.memory [[META0]], !amdgpu.no.remote.memory.access [[META0]]
21+
; CHECK-NEXT: ret i32 [[RES_I]]
22+
;
23+
%res = call i32 @atomic_xor(ptr addrspace(1) %ptr, i32 %val)
24+
ret i32 %res
25+
}
26+
27+
!0 = !{}
28+
;.
29+
; CHECK: [[META0]] = !{}
30+
;.

0 commit comments

Comments
 (0)