<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/99162>99162</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `WaveActiveAllEqual` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
backend:DirectX,
HLSL,
backend:SPIR-V,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement `WaveActiveAllEqual` clang builtin,
- [ ] Link `WaveActiveAllEqual` clang builtin with `hlsl_intrinsics.h`
- [ ] Add sema checks for `WaveActiveAllEqual` to `CheckHLSLBuiltinFunctionCall` in `SemaChecking.cpp`
- [ ] Add codegen for `WaveActiveAllEqual` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/WaveActiveAllEqual.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/WaveActiveAllEqual-errors.hlsl`
- [ ] Create the `int_dx_WaveActiveAllEqual` intrinsic in `IntrinsicsDirectX.td`
- [ ] Create the `DXILOpMapping` of `int_dx_WaveActiveAllEqual` to `115` in `DXIL.td`
- [ ] Create the `WaveActiveAllEqual.ll` and `WaveActiveAllEqual_errors.ll` tests in `llvm/test/CodeGen/DirectX/`
- [ ] Create the `int_spv_WaveActiveAllEqual` intrinsic in `IntrinsicsSPIRV.td`
- [ ] In SPIRVInstructionSelector.cpp create the `WaveActiveAllEqual` lowering and map it to `int_spv_WaveActiveAllEqual` in `SPIRVInstructionSelector::selectIntrinsic`.
- [ ] Create SPIR-V backend test case in `llvm/test/CodeGen/SPIRV/hlsl-intrinsics/WaveActiveAllEqual.ll`
## DirectX
| DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
| ----------- | ----------- | ------------ | ------------- |
| 115 | WaveActiveAllEqual | 6.0 | ('library', 'compute', 'amplification', 'mesh', 'pixel', 'vertex', 'hull', 'domain', 'geometry', 'raygeneration', 'intersection', 'anyhit', 'closesthit', 'miss', 'callable', 'node') |
## SPIR-V
# [OpGroupNonUniformAllEqual](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpGroupNonUniformAllEqual):
## Description:
Evaluates a value for all active invocations in the [group](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Group). The
result is **true** if *Value* is equal for all active invocations in the
group. Otherwise, the result is **false**.
*Result Type* must be a [*Boolean type*](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Boolean).
*Execution* is a [*Scope*](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Scope_-id-) that identifies the group of
invocations affected by this command. It must be **Subgroup**.
*Value* must be a scalar or vector of [*floating-point
type*](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Floating), [*integer type*](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Integer), or [*Boolean
type*](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Boolean). The compare operation is based on this type, and if it
is a floating-point type, an ordered-and-equal compare is used.
[Capability](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Capability):
**GroupNonUniformVote**
[Missing before](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Unified) **version 1.3**.
<table style="width:100%;">
<colgroup>
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
<col style="width: 16%" />
</colgroup>
<thead>
<tr>
<th>Word Count</th>
<th>Opcode</th>
<th>Results</th>
<th>Operands</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p>5</p></td>
<td class="tableblock halign-left valign-top"><p>336</p></td>
<td
class="tableblock halign-left valign-top"><p><em><id></em><br />
<em>Result Type</em></p></td>
<td class="tableblock halign-left valign-top"><p><a
href="#ResultId"><em>Result <id></em></a></p></td>
<td class="tableblock halign-left valign-top"><p><a
href="#Scope_-id-"><em>Scope <id></em></a><br />
<em>Execution</em></p></td>
<td
class="tableblock halign-left valign-top"><p><em><id></em><br />
<em>Value</em></p></td>
</tr>
</tbody>
</table>
## Test Case(s)
### Example 1
```hlsl
//dxc WaveActiveAllEqual_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export bool4 fn(float4 p1) {
return WaveActiveAllEqual(p1);
}
```
## HLSL:
Returns true if the expression is the same for every active lane in the current wave (and thus uniform across it).
## Syntax
``` syntax
<bool-type> WaveActiveAllEqual(
<type> expr
);
```
## Parameters
<dl> <dt>
*expr*
</dt> <dd>
The expression to evaluate.
`<type>` can be a basic scalar, vector, or matrix type.
</dd> </dl>
## Return value
Returns `true` for each component of `expr` that is the same for every active lane in the current wave.
`<bool-type>` will be a scalar, vector, or matrix of `bool`, matching the dimensionality of the input `<type>`.
For instance, an input `<type>` of `matrix<float, 4, 3>` will result in a return `<bool-type>` of `matrix<bool, 4, 3>`.
## Remarks
This function is supported from shader model 6.0 in all shader stages.
## See also
<dl> <dt>
[Overview of Shader Model 6](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/hlsl-shader-model-6-0-features-for-direct3d-12.md)
</dt> <dt>
[Shader Model 6](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/shader-model-6-0.md)
</dt> </dl>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWV9T4zgS_zTiRWWXI5MAD3kIgcxRNbNsDezsvlGy1Y51yJJPkgO5T3_Vkp04EGB267h9OIqCqNXuP7_ulrsV7pxca4A5mV6S6dUJ73xt7Lzi9t9Gq5PCiO08oWR6Scn0it40rYIGtKdklv3ON7AovdzAQqnrf3VckVlGS8X1mhadVF5qwpYkW-yf_yr1408-Sp-kr5G3Vk49SO2t1E6WLq3JLDsQuhCCOmg4LWsoHx2tjH1bhze4t0TOf3y9-3oZla06XXpp9JKrwCU1ct1BwwO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