[llvm] [SPIR-V] Complete SPV_INTEL_16bit_atomics extension support (PR #184312)

Viktoria Maximova via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 10:08:33 PDT 2026


================
@@ -0,0 +1,31 @@
+; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
+
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_16bit_atomics %s -o - | FileCheck %s
+
+; CHECK-ERROR: LLVM ERROR: 16-bit integer atomic operations require the following SPIR-V extension: SPV_INTEL_16bit_atomics
+
+; CHECK-DAG: Capability Int16
+; CHECK-DAG: Capability AtomicInt16CompareExchangeINTEL
+; CHECK-DAG: Extension "SPV_INTEL_16bit_atomics"
+; CHECK-DAG: %[[#TyInt16:]] = OpTypeInt 16 0
+; CHECK-DAG: %[[#TyInt16Ptr:]] = OpTypePointer {{[a-zA-Z]+}} %[[#TyInt16]]
+; CHECK-DAG: %[[#TyInt32:]] = OpTypeInt 32 0
+; CHECK-DAG: %[[#Value1:]] = OpConstant %[[#TyInt16]] 1{{$}}
+; CHECK-DAG: %[[#Value42:]] = OpConstant %[[#TyInt16]] 42{{$}}
+; CHECK-DAG: %[[#Const0:]] = OpConstantNull %[[#TyInt16]]
+; CHECK-DAG: %[[#Int16Ptr:]] = OpVariable %[[#TyInt16Ptr]] CrossWorkgroup %[[#Const0]]
+; CHECK-DAG: %[[#Scope:]] = OpConstantNull %[[#TyInt32]]
+; CHECK-DAG: %[[#MemSeqCst:]] = OpConstant %[[#TyInt32]] 16{{$}}
+
+; CHECK: OpAtomicExchange %[[#TyInt16]] %[[#Int16Ptr]] %[[#Scope]] %[[#MemSeqCst]] %[[#Value42]]
+; CHECK: OpAtomicCompareExchange %[[#TyInt16]] %[[#]] %[[#Scope]] %[[#MemSeqCst]] %[[#MemSeqCst]] %[[#Value42]] %[[#Value1]]
----------------
vmaksimo wrote:

`OpAtomicCompareExchangeWeak` is deprecated since SPIR-V 1.4 - `OpAtomicCompareExchange` is used instead. Did not add the test case only for this very instruction

https://github.com/llvm/llvm-project/pull/184312


More information about the llvm-commits mailing list