Skip to content

Implement the and HLSL Function #125604

Closed
@farzonl

Description

@farzonl
  • Implement the and api in hlsl_intrinsics.h
    - [ ] Investigate to see if we can use __builtin_reduce_and
  • If a clang builtin is needed add sema checks for and to CheckHLSLBuiltinFunctionCall in SemaHLSL.cpp
  • If codegen is needed, add codegen for and to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/and.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/and-errors.hlsl

DirectX

There were no DXIL opcodes found for and.

SPIR-V

There were no SPIR-V opcodes found for and.

Test Case(s)

Example 1

//dxc and_test.hlsl -T lib_6_8 -enable-16bit-types -O0

export bool4 fn(bool4 p1, bool4 p2) {
    return and(p1, p2);
}

HLSL:

Logically ands a vector and produces a bool vector output

Syntax

bool<> and(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 and(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"metabugIssue 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