Skip to content

Commit

Permalink
AMDGPU: Add tests for atomicrmw handling of new metadata
Browse files Browse the repository at this point in the history
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
  • Loading branch information
arsenm committed Apr 18, 2024
1 parent 9606716 commit ee3a6cf
Show file tree
Hide file tree
Showing 16 changed files with 18,408 additions and 1,640 deletions.
2,161 changes: 1,744 additions & 417 deletions llvm/test/CodeGen/AMDGPU/flat_atomics_i32_system.ll

Large diffs are not rendered by default.

2,268 changes: 1,875 additions & 393 deletions llvm/test/CodeGen/AMDGPU/flat_atomics_i64_system.ll

Large diffs are not rendered by default.

2,381 changes: 1,918 additions & 463 deletions llvm/test/CodeGen/AMDGPU/global_atomics_i32_system.ll

Large diffs are not rendered by default.

2,328 changes: 1,961 additions & 367 deletions llvm/test/CodeGen/AMDGPU/global_atomics_i64_system.ll

Large diffs are not rendered by default.

741 changes: 741 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fadd.ll

Large diffs are not rendered by default.

672 changes: 672 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fmax.ll

Large diffs are not rendered by default.

671 changes: 671 additions & 0 deletions llvm/test/CodeGen/AMDGPU/global_atomics_scan_fmin.ll

Large diffs are not rendered by default.

3,717 changes: 3,717 additions & 0 deletions llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-f32-system.ll

Large diffs are not rendered by default.

1,685 changes: 1,685 additions & 0 deletions llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-f64-system.ll

Large diffs are not rendered by default.

828 changes: 828 additions & 0 deletions llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-i32-system.ll

Large diffs are not rendered by default.

828 changes: 828 additions & 0 deletions llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-i64-system.ll

Large diffs are not rendered by default.

Large diffs are not rendered by default.

859 changes: 859 additions & 0 deletions llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomic-v2f16-system.ll

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ define i32 @test_atomicrmw_xor_0_global_system(ptr addrspace(1) %ptr) {
}


define i32 @test_atomicrmw_or_0_global_system__metadata(ptr addrspace(1) %ptr) {
; CHECK-LABEL: define i32 @test_atomicrmw_or_0_global_system__metadata(
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]]) {
; 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]]
; CHECK-NEXT: ret i32 [[RES]]
;
%res = atomicrmw or ptr addrspace(1) %ptr, i32 0 seq_cst, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
ret i32 %res
}

!0 = !{}
;.
; CHECK: [[META0]] = !{}
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/Transforms/InferAddressSpaces/AMDGPU/basic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,14 @@ entry:
ret void
}

; CHECK-LABEL: @atomicrmw_add_global_to_flat_preserve_amdgpu_md(
; 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
define i32 @atomicrmw_add_global_to_flat_preserve_amdgpu_md(ptr addrspace(1) %global.ptr, i32 %y) #0 {
%cast = addrspacecast ptr addrspace(1) %global.ptr to ptr
%ret = atomicrmw add ptr %cast, i32 %y seq_cst, align 4, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
ret i32 %ret
}

attributes #0 = { nounwind }

!0 = !{}
30 changes: 30 additions & 0 deletions llvm/test/Transforms/Inline/AMDGPU/inline-atomicrmw-md-preserve.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes=inline < %s | FileCheck %s
; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes='cgscc(inline)' < %s | FileCheck %s

; Ensure that custom metadata survives inlining

define i32 @atomic_xor(ptr addrspace(1) %ptr, i32 %val) {
; CHECK-LABEL: define i32 @atomic_xor(
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]], i32 [[VAL:%.*]]) {
; 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]]
; CHECK-NEXT: ret i32 [[RES]]
;
%res = atomicrmw xor ptr addrspace(1) %ptr, i32 %val monotonic, !amdgpu.no.fine.grained.memory !0, !amdgpu.no.remote.memory.access !0
ret i32 %res
}

define i32 @caller(ptr addrspace(1) %ptr, i32 %val) {
; CHECK-LABEL: define i32 @caller(
; CHECK-SAME: ptr addrspace(1) [[PTR:%.*]], i32 [[VAL:%.*]]) {
; 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]]
; CHECK-NEXT: ret i32 [[RES_I]]
;
%res = call i32 @atomic_xor(ptr addrspace(1) %ptr, i32 %val)
ret i32 %res
}

!0 = !{}
;.
; CHECK: [[META0]] = !{}
;.

0 comments on commit ee3a6cf

Please sign in to comment.