<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99202>99202</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `InterlockedCompareStoreFloatBitwise` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
backend:DirectX,
HLSL,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement `InterlockedCompareStoreFloatBitwise` clang builtin,
- [ ] Link `InterlockedCompareStoreFloatBitwise` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `InterlockedCompareStoreFloatBitwise` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `InterlockedCompareStoreFloatBitwise` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/InterlockedCompareStoreFloatBitwise.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/InterlockedCompareStoreFloatBitwise-errors.hlsl`
- [ ] Create the `int_dx_InterlockedCompareStoreFloatBitwise` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_InterlockedCompareStoreFloatBitwise` to `79` in `DXIL.td`
- [ ] Create the `InterlockedCompareStoreFloatBitwise.ll` and `InterlockedCompareStoreFloatBitwise_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
## DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 79 | AtomicCompareExchange | 6.0 | () |
## SPIR-V
There is no support for `InterlockedCompareStoreFloatBitwise` when targeting SPIR-V.
## Test Case(s)
### Example 1
```hlsl
//dxc InterlockedCompareStoreFloatBitwise_test.hlsl -T lib_6_8 -enable-16bit-types -O0
RWStructuredBuffer<float> buffer : register(u0);
[numthreads(1, 1, 1)]
export void fn(uint3 dispatchThreadID : SV_DispatchThreadID, float p1, float p2) {
int index = dispatchThreadID.x;
return InterlockedCompareStoreFloatBitwise(buffer[index], p1, p2);
}
```
## HLSL:
## Syntax
```syntax
void InterlockedCompareStoreFloatBitwise(float32_only result, float compare, float value);
```
```syntax
void InterlockedCompareStoreFloatBitwise(uint byteOffest, float compare, float value);
```
## Type Description
| Name | [**Template Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md)| [**Component Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md) | Size |
|-------|--------------------------------------------------------------------|----------------------------------------------------------------------|------|
| *ret* | **void** | **void** | 0 |
| *result* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](../WinProg/windows-data-types) | 1 |
| *compare* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](../WinProg/windows-data-types) | 1 |
| *value* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](../WinProg/windows-data-types) | 1 |
## Type Description
| Name | [**Template Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md)| [**Component Type**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-data-types.md) | Size |
|-------|--------------------------------------------------------------------|----------------------------------------------------------------------|------|
| *ret* | **void** | **void** | 0 |
| *byteOffest* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**uint**](../WinProg/windows-data-types) | 1 |
| *compare* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](../WinProg/windows-data-types) | 1 |
| *value* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md) | [**float**](../WinProg/windows-data-types) | 1 |
## Minimum Shader Model
This function is supported in the following shader models.
|Shader Model | Supported|
|-------------|----------|
|[Shader Model 6.3](https://github.com/microsoft/DirectXShaderCompiler/wiki/Shader-Model-6.3) and higher shader models | yes |
## Shader Stages
## See also
- [**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
- **See [InterlockedCompareStoreFloatBitwise](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_Int64_and_Float_Atomics.html#interlockedcomparestorefloatbitwise)**
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWUtv4zgS_jX0hZAgU34efPAjnjWQbAbjYGZuBiWWJW4oUiCpxJlfvyApW3aSTru7d4FuIIa7Y5fIqq--ekgsU2N4IQFmaLhAw1WPNrZUeran-h8lRS9T7GUWYTRcYDRc4U1VC6hAWoxGyUZa0ELlj8CWqqqphq1VGtZCUbvg9pkbQKME54LKAmcNF5ZLRJYomXcKb7l8_F5d-Jnb0m0uhRE7Lq3m0vDcxCUaJRdW5oxhAxXFeQn5o8F7pb_BqFVu8dJt_dft9nYRrK8bmVuu5JIK4VZx6VZtoaJ-JZdFnNf1e0hyxaAA-V0obipuz0DcHGrdGV_-1oq_ZtmCsabV6ClFZO1kiKyXisFvIJ0NRNYt0waR9RUwYxeIL3L_gVHHWmvRe7C51mIEWitt3jW81EAtYFuCs8il3bHD7kqyT8nUMrs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