Skip to content

Implement the or HLSL Function #125605

Closed
@farzonl

Description

@farzonl
  • Implement the or api in hlsl_intrinsics.h
    - [ ] Investigate to see if we can use __builtin_reduce_or.
  • 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

//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 ors a vector and produces a bool vector output

Syntax

bool<> or(bool<> x, bool<> y);

Type Description

Name Template Type Component Type Size
ret scalar, vector, or matrix bool any
x scalar, vector, or matrix bool any
y scalar, vector, or matrix 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

int3 X = {1, 1, 1};
int3 Y = {0, 0, 0};
bool3 Cond = X || Y;

See also

Metadata

Metadata

Assignees

Labels

HLSLHLSL Language Supportbot:HLSLclang:codegenIR generation bugs: mangling, exceptions, etc.clang:frontendLanguage frontend issues, e.g. anything involving "Sema"metaissueIssue to collect references to a group of similar or related issues.

Type

No type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions