|
1 | 1 | import LLVM |
| 2 | +import InteractiveUtils |
2 | 3 |
|
3 | 4 | using UnsafeAtomics: UnsafeAtomics, acquire, release, acq_rel, seq_cst |
4 | 5 | using UnsafeAtomics.Internal: OP_RMW_TABLE, inttypes |
@@ -34,6 +35,14 @@ function check_default_ordering(xs::AbstractArray{T}, x1::T, x2::T) where T |
34 | 35 | xs[1] = x1 |
35 | 36 | @test rmw(ptr, x2) === x1 |
36 | 37 | @test xs[1] === op(x1, x2) |
| 38 | + |
| 39 | + # Check dispatch to LLVM atomic OP instead of CAS loop. |
| 40 | + if (op == +) || (op == -) |
| 41 | + IR = sprint(io->InteractiveUtils.code_llvm(io, |
| 42 | + UnsafeAtomics.modify!, |
| 43 | + typeof.((ptr, +, T(1))))) |
| 44 | + @test occursin("atomicrmw", IR) |
| 45 | + end |
37 | 46 | end |
38 | 47 | end |
39 | 48 | end |
@@ -80,6 +89,14 @@ function test_explicit_ordering(xs::AbstractArray{T}, x1::T, x2::T) where T |
80 | 89 | (x1 => op(x1, x2)) |
81 | 90 | @test xs[1] === op(x1, x2) |
82 | 91 | end |
| 92 | + |
| 93 | + # Check dispatch to LLVM atomic OP instead of CAS loop. |
| 94 | + if (op == +) || (op == -) |
| 95 | + IR = sprint(io->InteractiveUtils.code_llvm(io, |
| 96 | + UnsafeAtomics.modify!, |
| 97 | + typeof.((ptr, +, T(1), seq_cst, UnsafeAtomics.singlethread)))) |
| 98 | + @test occursin("atomicrmw", IR) |
| 99 | + end |
83 | 100 | end |
84 | 101 | end |
85 | 102 | end |
|
0 commit comments