[llvm-branch-commits] [clang] [llvm] [HLSL] Add `InterlockedCompareStoreFloatBitwise` function and resource methods (PR #222166)
Helena Kotas via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 22 14:52:03 PDT 2026
================
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -triple \
+// RUN: dxil-pc-shadermodel6.6-library %s -emit-llvm -disable-llvm-passes -o - | \
+// RUN: FileCheck %s --check-prefixes=CHECK,DXCHECK
+
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -triple \
+// RUN: spirv-pc-vulkan-library %s -emit-llvm -disable-llvm-passes -o - | \
+// RUN: FileCheck %s --check-prefixes=CHECK,SPVCHECK
+
+// Test basic lowering of HLSL InterlockedCompareStoreFloatBitwise to `cmpxchg
+// monotonic`. `cmpxchg` takes an integer, so the float arguments become their
+// bit patterns first. The operation reports nothing, so the `cmpxchg` result
+// stays unused.
+
+groupshared float gs_f32;
+
+// CHECK-LABEL: define {{.*}}void @{{.*}}test_float
+// CHECK: [[CMP:%.*]] = bitcast float %{{.*}} to i32
+// CHECK-NEXT: [[VAL:%.*]] = bitcast float %{{.*}} to i32
+// DXCHECK-NEXT: cmpxchg ptr addrspace(3) {{.*}}@gs_f32{{.*}}, i32 [[CMP]], i32 [[VAL]] syncscope("workgroup") monotonic monotonic
+// SPVCHECK-NEXT: cmpxchg ptr addrspace(3) {{.*}}@gs_f32{{.*}}, i32 [[CMP]], i32 [[VAL]] syncscope("workgroup") monotonic monotonic
----------------
hekota wrote:
```suggestion
// CHECK-NEXT: cmpxchg ptr addrspace(3) {{.*}}@gs_f32{{.*}}, i32 [[CMP]], i32 [[VAL]] syncscope("workgroup") monotonic monotonic
```
https://github.com/llvm/llvm-project/pull/222166
More information about the llvm-branch-commits
mailing list