| 1 |
; RUN: llc -O0 -mtriple=spirv32v1.3-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32v1.3-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
;; __kernel void testAtomicCompareExchangeExplicit_cl20( |
| 5 |
;; volatile global atomic_int* object, |
| 6 |
;; global int* expected, |
| 7 |
;; int desired) |
| 8 |
;; { |
| 9 |
;; Values of memory order and memory scope arguments correspond to SPIR-2.0 spec. |
| 10 |
;; atomic_compare_exchange_strong_explicit(object, expected, desired, |
| 11 |
;; memory_order_release, // 3 |
| 12 |
;; memory_order_relaxed // 0 |
| 13 |
;; ); // by default, assume device scope = 2 |
| 14 |
;; atomic_compare_exchange_strong_explicit(object, expected, desired, |
| 15 |
;; memory_order_acq_rel, // 4 |
| 16 |
;; memory_order_relaxed, // 0 |
| 17 |
;; memory_scope_work_group // 1 |
| 18 |
;; ); |
| 19 |
;; atomic_compare_exchange_weak_explicit(object, expected, desired, |
| 20 |
;; memory_order_release, // 3 |
| 21 |
;; memory_order_relaxed // 0 |
| 22 |
;; ); // by default, assume device scope = 2 |
| 23 |
;; atomic_compare_exchange_weak_explicit(object, expected, desired, |
| 24 |
;; memory_order_acq_rel, // 4 |
| 25 |
;; memory_order_relaxed, // 0 |
| 26 |
;; memory_scope_work_group // 1 |
| 27 |
;; ); |
| 28 |
;; } |
| 29 |
|
| 30 |
; CHECK-SPIRV: %[[#int:]] = OpTypeInt 32 0 |
| 31 |
;; Constants below correspond to the SPIR-V spec |
| 32 |
; CHECK-SPIRV-DAG: %[[#DeviceScope:]] = OpConstant %[[#int]] 1{{$}} |
| 33 |
; CHECK-SPIRV-DAG: %[[#WorkgroupScope:]] = OpConstant %[[#int]] 2{{$}} |
| 34 |
; CHECK-SPIRV-DAG: %[[#ReleaseMemSem:]] = OpConstant %[[#int]] 4{{$}} |
| 35 |
; CHECK-SPIRV-DAG: %[[#RelaxedMemSem:]] = OpConstantNull %[[#int]] |
| 36 |
; CHECK-SPIRV-DAG: %[[#AcqRelMemSem:]] = OpConstant %[[#int]] 8{{$}} |
| 37 |
|
| 38 |
; CHECK-SPIRV: %[[#]] = OpAtomicCompareExchange %[[#]] %[[#]] %[[#DeviceScope]] %[[#ReleaseMemSem]] %[[#RelaxedMemSem]] |
| 39 |
; CHECK-SPIRV: %[[#]] = OpAtomicCompareExchange %[[#]] %[[#]] %[[#WorkgroupScope]] %[[#AcqRelMemSem]] %[[#RelaxedMemSem]] |
| 40 |
; CHECK-SPIRV: %[[#]] = OpAtomicCompareExchangeWeak %[[#]] %[[#]] %[[#DeviceScope]] %[[#ReleaseMemSem]] %[[#RelaxedMemSem]] |
| 41 |
; CHECK-SPIRV: %[[#]] = OpAtomicCompareExchangeWeak %[[#]] %[[#]] %[[#WorkgroupScope]] %[[#AcqRelMemSem]] %[[#RelaxedMemSem]] |
| 42 |
|
| 43 |
define dso_local spir_kernel void @testAtomicCompareExchangeExplicit_cl20(ptr addrspace(1) noundef %object, ptr addrspace(1) noundef %expected, i32 noundef %desired) local_unnamed_addr { |
| 44 |
entry: |
| 45 |
%0 = addrspacecast ptr addrspace(1) %object to ptr addrspace(4) |
| 46 |
%1 = addrspacecast ptr addrspace(1) %expected to ptr addrspace(4) |
| 47 |
%call = call spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_(ptr addrspace(4) noundef %0, ptr addrspace(4) noundef %1, i32 noundef %desired, i32 noundef 3, i32 noundef 0) |
| 48 |
%call1 = call spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(ptr addrspace(4) noundef %0, ptr addrspace(4) noundef %1, i32 noundef %desired, i32 noundef 4, i32 noundef 0, i32 noundef 1) |
| 49 |
%call2 = call spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_(ptr addrspace(4) noundef %0, ptr addrspace(4) noundef %1, i32 noundef %desired, i32 noundef 3, i32 noundef 0) |
| 50 |
%call3 = call spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(ptr addrspace(4) noundef %0, ptr addrspace(4) noundef %1, i32 noundef %desired, i32 noundef 4, i32 noundef 0, i32 noundef 1) |
| 51 |
ret void |
| 52 |
} |
| 53 |
|
| 54 |
declare spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_(ptr addrspace(4) noundef, ptr addrspace(4) noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr |
| 55 |
|
| 56 |
declare spir_func zeroext i1 @_Z39atomic_compare_exchange_strong_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(ptr addrspace(4) noundef, ptr addrspace(4) noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr |
| 57 |
|
| 58 |
declare spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_(ptr addrspace(4) noundef, ptr addrspace(4) noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr |
| 59 |
|
| 60 |
declare spir_func zeroext i1 @_Z37atomic_compare_exchange_weak_explicitPU3AS4VU7_AtomiciPU3AS4ii12memory_orderS4_12memory_scope(ptr addrspace(4) noundef, ptr addrspace(4) noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr |