Skip to content

[HLSL] Implement isnormal HLSL function #156069

@spall

Description

@spall

In DXC we are retrospectively adding an isnormal HLSL function that is implemented using the existing DXIL opcode. This was tested in previous HLKs by mutating DXIL, so it is supported in the ecosystem, just not exposed directly from HLSL. We need to add this to Clang as well.

Implement the isnormal function with half and float overloads.

Targeting DirectX:
The 32 bit overload should use the IsNormal DXIL Op
In SM6.8 and earlier the 16 bit overload should be emulated using LLVM IR
In SM6.9 and later the 16 bit overload should use the IsNormal DXIL Op
Add unit tests showing the correct IR/DXIL Op is generated for each float size and SM.

Targeting SPIRV:
OpIsNormal requires the kernel capability, so it cannot be used; therefore, the isnormal op should be emulated.
IsNormal = !(Nan || Inf || Zero || Subnormal)
In the bit pattern of a 16 bit or 32 bit float; a normal number corresponds to one whose exponent bits are neither all zeros nor all ones.
Add unit tests showing isnormal is emulated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HLSLHLSL Language Support

    Type

    No type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions