<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/125605>125605</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Implement the `or` HLSL Function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
metabug,
HLSL,
bot:HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
farzonl
</td>
</tr>
</table>
<pre>
- [ ] Implement the `or` api in `hlsl_intrinsics.h`
- [ ] If a clang builtin is needed add sema checks for `or` to `CheckHLSLBuiltinFunctionCall` in `SemaHLSL.cpp`
- [ ] If codegen is needed, add codegen for `or` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`
- [ ] Add codegen tests to `clang/test/CodeGenHLSL/builtins/or.hlsl`
- [ ] Add sema tests to `clang/test/SemaHLSL/BuiltIns/or-errors.hlsl`
## DirectX
There were no DXIL opcodes found for `or`.
## SPIR-V
There were no SPIR-V opcodes found for `or`.
## Test Case(s)
### Example 1
```hlsl
//dxc or_test.hlsl -T lib_6_8 -enable-16bit-types -O0
export bool4 fn(bool4 p1, bool4 p2) {
return or(p1, p2);
}
```
## HLSL:
Logically `or`s a vector and produces a bool vector output
## Syntax
```syntax
bool<> or(bool<> x, bool<> y);
```
## 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* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool** | any |
| *x* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool** | any |
| *y* | [**scalar**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-scalar.md), [**vector**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-vector.md), or [**matrix**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-matrix.md) | **bool** | any |
## Minimum Shader Model
This function is supported in the following shader models.
|Shader Model | Supported|
|-------------|----------|
|All Shader Models with HLSL 2021 Language Mode | yes |
## Shader Stages
**All Shader Stages**
## Remarks
In HLSL 2021 `or(X, Y);` is a replacement for
```hlsl
int3 X = {1, 1, 1};
int3 Y = {0, 0, 0};
bool3 Cond = X || Y;
```
## See also
- [**Intrinsic Functions (DirectX HLSL)**](https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src//direct3dhlsl/../direct3dhlsl/dx-graphics-hlsl-intrinsic-functions.md)
- **See [HLSL 2021 Logical operation short-circuiting for scalars](https://github.com/microsoft/DirectXShaderCompiler/wiki/HLSL-2021#logical-operation-short-circuiting-for-scalars)**
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWF9v2zYQ_zT0y0GGRPnvgx8cO-4CpNvQBEP6FNDS2eZCkQJJNXY__XCkFC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