Skip to content

[SPIR-V] Legalize the llvm.is.fpclass intrinsic #137892

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

Closed
Icohedron opened this issue Apr 29, 2025 · 1 comment
Closed

[SPIR-V] Legalize the llvm.is.fpclass intrinsic #137892

Icohedron opened this issue Apr 29, 2025 · 1 comment
Labels
backend:SPIR-V question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@Icohedron
Copy link
Contributor

Description

LLVM Language Reference: llvm.is.fpclass

The lowering of llvm.is.fpclass depends on the compile-time constant operand i32 <test>.
Valid bits for <test> are defined in an enum named FPClassTest.
The following FPClassTest cases are of interest:

  • FPClassTest::fcInf, FPClassTest::fcNan, FPClassTest::fcFinite, FPClassTest::fcNormal map directly to SPIR-V Ops

The lowering of llvm.is.fpclass to both SPIR-V and DirectX will simplify the codegen for HLSL intrinsics isinf, isnan, and isfinite

SPIRV Ops

  • OpIsInf
  • OpIsNan
  • OpIsNormal
  • OpIsFinite

Note: The SPIRV specification states that the results of these ops depends on the floating-point encoding used. However, there are currently no alternative floating-point encodings listed in the specification.

@Icohedron
Copy link
Contributor Author

Icohedron commented May 1, 2025

As mentioned in #87777 (comment), isnan and isinf will not use llvm.is.fpclass because they should not be removed by fast-math optimizations.
isfinite should be implemented with its own intrinsic as well, to be consistent with isnan and isinf.

@Icohedron Icohedron closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2025
@github-project-automation github-project-automation bot moved this to Closed in HLSL Support May 1, 2025
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:SPIR-V question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
Status: Closed
Development

No branches or pull requests

3 participants