Skip to content

Implement the isnan HLSL Function #99132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
12 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 0 comments
Open
12 tasks
Tracked by #99235

Implement the isnan HLSL Function #99132

farzonl opened this issue Jul 16, 2024 · 0 comments
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

  • Implement isnan clang builtin,
  • Link isnan clang builtin with hlsl_intrinsics.h
  • Add sema checks for isnan to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for isnan to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/isnan.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/isnan-errors.hlsl
  • Create the int_dx_isnan intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_isnan to 8 in DXIL.td
  • Create the isnan.ll and isnan_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_isnan intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the isnan lowering and map it to int_spv_isnan in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/isnan.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
8 IsNaN 6.0 ()

SPIR-V

OpIsNan:

Description:

Result is true if x is a NaN for the floating-point encoding used
by the type of x, otherwise result is false.

Result Type must be a scalar or vector of Boolean
type
.

x must be a scalar or vector of floating-point type. It
must have the same number of components as Result Type.

Results are computed per component.

Word Count Opcode Results Operands

4

156

<id>
Result Type

Result <id>

<id>
x

Test Case(s)

Example 1

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

export bool4 fn(float4 p1) {
    return isnan(p1);
}

HLSL:

Determines if the specified value is NAN or QNAN.

ret isnan(x)

Parameters

Item Description
x
[in] The specified value.

Return Value

Returns a value of the same size as the input, with a value set to True if the x parameter is NAN or QNAN. Otherwise, False.

Type Description

Name Template Type Component Type Size
x scalar, vector, or matrix float any
ret scalar, vector, or matrix bool as input

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 2 (DirectX HLSL) and higher shader models yes
Shader Model 1 (DirectX HLSL) yes (vs_1_1 only)

Requirements

Requirement Value
Header
Corecrt_math.h

See also

Intrinsic Functions (DirectX HLSL)

@farzonl farzonl added backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
@damyanp damyanp moved this to Ready in HLSL Support Oct 30, 2024
@damyanp damyanp moved this from Ready to Planning in HLSL Support Oct 30, 2024
@pow2clk pow2clk moved this from Planning to Designing in HLSL Support Nov 19, 2024
@damyanp damyanp removed the status in HLSL Support Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: No status
Development

No branches or pull requests

1 participant