| 1 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s |
| 5 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 6 |
|
| 7 |
; CHECK: %[[#Int:]] = OpTypeInt 32 0 |
| 8 |
; CHECK-DAG: %[[#Float:]] = OpTypeFloat 32 |
| 9 |
; CHECK-DAG: %[[#Scope_CrossDevice:]] = OpConstantNull %[[#Int]] |
| 10 |
; CHECK-DAG: %[[#Value:]] = OpConstant %[[#Int]] 42{{$}} |
| 11 |
; CHECK-DAG: %[[#FPValue:]] = OpConstant %[[#Float]] 42{{$}} |
| 12 |
; CHECK-DAG: %[[#Scope_Invocation:]] = OpConstant %[[#Int]] 4{{$}} |
| 13 |
; CHECK-DAG: %[[#MemSem_SeqCst:]] = OpConstant %[[#Int]] 16{{$}} |
| 14 |
; CHECK-DAG: %[[#Scope_Subgroup:]] = OpConstant %[[#Int]] 3{{$}} |
| 15 |
; CHECK-DAG: %[[#Scope_Workgroup:]] = OpConstant %[[#Int]] 2{{$}} |
| 16 |
; CHECK-DAG: %[[#Scope_Device:]] = OpConstant %[[#Int]] 1{{$}} |
| 17 |
; CHECK-DAG: %[[#PointerType:]] = OpTypePointer CrossWorkgroup %[[#Int]] |
| 18 |
; CHECK-DAG: %[[#FPPointerType:]] = OpTypePointer CrossWorkgroup %[[#Float]] |
| 19 |
; CHECK-DAG: %[[#Pointer:]] = OpVariable %[[#PointerType]] CrossWorkgroup |
| 20 |
; CHECK-DAG: %[[#FPPointer:]] = OpVariable %[[#FPPointerType]] CrossWorkgroup |
| 21 |
|
| 22 |
@ui = common dso_local addrspace(1) global i32 0, align 4 |
| 23 |
@f = common dso_local local_unnamed_addr addrspace(1) global float 0.000000e+00, align 4 |
| 24 |
|
| 25 |
define dso_local spir_func void @test_singlethread_atomicrmw() local_unnamed_addr { |
| 26 |
entry: |
| 27 |
%0 = atomicrmw xchg ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 28 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 29 |
%1 = atomicrmw xchg ptr addrspace(1) @f, float 42.000000e+00 syncscope("singlethread") seq_cst |
| 30 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Float:]] %[[#FPPointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#FPValue:]] |
| 31 |
%2 = atomicrmw add ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 32 |
; CHECK: %[[#]] = OpAtomicIAdd %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 33 |
%3 = atomicrmw sub ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 34 |
; CHECK: %[[#]] = OpAtomicISub %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 35 |
%4 = atomicrmw or ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 36 |
; CHECK: %[[#]] = OpAtomicOr %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 37 |
%5 = atomicrmw xor ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 38 |
; CHECK: %[[#]] = OpAtomicXor %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 39 |
%6 = atomicrmw and ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 40 |
; CHECK: %[[#]] = OpAtomicAnd %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 41 |
%7 = atomicrmw max ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 42 |
; CHECK: %[[#]] = OpAtomicSMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 43 |
%8 = atomicrmw min ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 44 |
; CHECK: %[[#]] = OpAtomicSMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 45 |
%9 = atomicrmw umax ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 46 |
; CHECK: %[[#]] = OpAtomicUMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 47 |
%10 = atomicrmw umin ptr addrspace(1) @ui, i32 42 syncscope("singlethread") seq_cst |
| 48 |
; CHECK: %[[#]] = OpAtomicUMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Invocation:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 49 |
|
| 50 |
ret void |
| 51 |
} |
| 52 |
|
| 53 |
define dso_local spir_func void @test_subgroup_atomicrmw() local_unnamed_addr { |
| 54 |
entry: |
| 55 |
%0 = atomicrmw xchg ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 56 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 57 |
%1 = atomicrmw xchg ptr addrspace(1) @f, float 42.000000e+00 syncscope("subgroup") seq_cst |
| 58 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Float:]] %[[#FPPointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#FPValue:]] |
| 59 |
%2 = atomicrmw add ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 60 |
; CHECK: %[[#]] = OpAtomicIAdd %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 61 |
%3 = atomicrmw sub ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 62 |
; CHECK: %[[#]] = OpAtomicISub %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 63 |
%4 = atomicrmw or ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 64 |
; CHECK: %[[#]] = OpAtomicOr %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 65 |
%5 = atomicrmw xor ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 66 |
; CHECK: %[[#]] = OpAtomicXor %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 67 |
%6 = atomicrmw and ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 68 |
; CHECK: %[[#]] = OpAtomicAnd %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 69 |
%7 = atomicrmw max ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 70 |
; CHECK: %[[#]] = OpAtomicSMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 71 |
%8 = atomicrmw min ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 72 |
; CHECK: %[[#]] = OpAtomicSMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 73 |
%9 = atomicrmw umax ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 74 |
; CHECK: %[[#]] = OpAtomicUMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 75 |
%10 = atomicrmw umin ptr addrspace(1) @ui, i32 42 syncscope("subgroup") seq_cst |
| 76 |
; CHECK: %[[#]] = OpAtomicUMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Subgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 77 |
|
| 78 |
ret void |
| 79 |
} |
| 80 |
|
| 81 |
define dso_local spir_func void @test_workgroup_atomicrmw() local_unnamed_addr { |
| 82 |
entry: |
| 83 |
%0 = atomicrmw xchg ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 84 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 85 |
%1 = atomicrmw xchg ptr addrspace(1) @f, float 42.000000e+00 syncscope("workgroup") seq_cst |
| 86 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Float:]] %[[#FPPointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#FPValue:]] |
| 87 |
%2 = atomicrmw add ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 88 |
; CHECK: %[[#]] = OpAtomicIAdd %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 89 |
%3 = atomicrmw sub ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 90 |
; CHECK: %[[#]] = OpAtomicISub %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 91 |
%4 = atomicrmw or ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 92 |
; CHECK: %[[#]] = OpAtomicOr %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 93 |
%5 = atomicrmw xor ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 94 |
; CHECK: %[[#]] = OpAtomicXor %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 95 |
%6 = atomicrmw and ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 96 |
; CHECK: %[[#]] = OpAtomicAnd %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 97 |
%7 = atomicrmw max ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 98 |
; CHECK: %[[#]] = OpAtomicSMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 99 |
%8 = atomicrmw min ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 100 |
; CHECK: %[[#]] = OpAtomicSMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 101 |
%9 = atomicrmw umax ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 102 |
; CHECK: %[[#]] = OpAtomicUMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 103 |
%10 = atomicrmw umin ptr addrspace(1) @ui, i32 42 syncscope("workgroup") seq_cst |
| 104 |
; CHECK: %[[#]] = OpAtomicUMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Workgroup:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 105 |
|
| 106 |
ret void |
| 107 |
} |
| 108 |
|
| 109 |
define dso_local spir_func void @test_device_atomicrmw() local_unnamed_addr { |
| 110 |
entry: |
| 111 |
%0 = atomicrmw xchg ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 112 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 113 |
%1 = atomicrmw xchg ptr addrspace(1) @f, float 42.000000e+00 syncscope("device") seq_cst |
| 114 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Float:]] %[[#FPPointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#FPValue:]] |
| 115 |
%2 = atomicrmw add ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 116 |
; CHECK: %[[#]] = OpAtomicIAdd %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 117 |
%3 = atomicrmw sub ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 118 |
; CHECK: %[[#]] = OpAtomicISub %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 119 |
%4 = atomicrmw or ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 120 |
; CHECK: %[[#]] = OpAtomicOr %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 121 |
%5 = atomicrmw xor ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 122 |
; CHECK: %[[#]] = OpAtomicXor %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 123 |
%6 = atomicrmw and ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 124 |
; CHECK: %[[#]] = OpAtomicAnd %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 125 |
%7 = atomicrmw max ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 126 |
; CHECK: %[[#]] = OpAtomicSMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 127 |
%8 = atomicrmw min ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 128 |
; CHECK: %[[#]] = OpAtomicSMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 129 |
%9 = atomicrmw umax ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 130 |
; CHECK: %[[#]] = OpAtomicUMax %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 131 |
%10 = atomicrmw umin ptr addrspace(1) @ui, i32 42 syncscope("device") seq_cst |
| 132 |
; CHECK: %[[#]] = OpAtomicUMin %[[#Int]] %[[#Pointer:]] %[[#Scope_Device:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 133 |
|
| 134 |
ret void |
| 135 |
} |
| 136 |
|
| 137 |
define dso_local spir_func void @test_all_svm_devices_atomicrmw() local_unnamed_addr { |
| 138 |
entry: |
| 139 |
%0 = atomicrmw xchg ptr addrspace(1) @ui, i32 42 seq_cst |
| 140 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 141 |
%1 = atomicrmw xchg ptr addrspace(1) @f, float 42.000000e+00 seq_cst |
| 142 |
; CHECK: %[[#]] = OpAtomicExchange %[[#Float:]] %[[#FPPointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#FPValue:]] |
| 143 |
%2 = atomicrmw add ptr addrspace(1) @ui, i32 42 seq_cst |
| 144 |
; CHECK: %[[#]] = OpAtomicIAdd %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 145 |
%3 = atomicrmw sub ptr addrspace(1) @ui, i32 42 seq_cst |
| 146 |
; CHECK: %[[#]] = OpAtomicISub %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 147 |
%4 = atomicrmw or ptr addrspace(1) @ui, i32 42 seq_cst |
| 148 |
; CHECK: %[[#]] = OpAtomicOr %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 149 |
%5 = atomicrmw xor ptr addrspace(1) @ui, i32 42 seq_cst |
| 150 |
; CHECK: %[[#]] = OpAtomicXor %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 151 |
%6 = atomicrmw and ptr addrspace(1) @ui, i32 42 seq_cst |
| 152 |
; CHECK: %[[#]] = OpAtomicAnd %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 153 |
%7 = atomicrmw max ptr addrspace(1) @ui, i32 42 seq_cst |
| 154 |
; CHECK: %[[#]] = OpAtomicSMax %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 155 |
%8 = atomicrmw min ptr addrspace(1) @ui, i32 42 seq_cst |
| 156 |
; CHECK: %[[#]] = OpAtomicSMin %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 157 |
%9 = atomicrmw umax ptr addrspace(1) @ui, i32 42 seq_cst |
| 158 |
; CHECK: %[[#]] = OpAtomicUMax %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 159 |
%10 = atomicrmw umin ptr addrspace(1) @ui, i32 42 seq_cst |
| 160 |
; CHECK: %[[#]] = OpAtomicUMin %[[#Int]] %[[#Pointer:]] %[[#Scope_CrossDevice:]] %[[#MemSem_SeqCst:]] %[[#Value:]] |
| 161 |
|
| 162 |
ret void |
| 163 |
} |