[PATCH] D112025: Intrinsic for checking floating point class

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 18 04:43:22 PDT 2022


sepavloff added a comment.
Herald added a project: All.

This patch with the set of dependent patches provides support of the intrinsic in IR and CodeGen. Default lowering is implemented using integer operations, IEEE and Intel 80-bit extended precision formats are supported in it. Custom lowering for non-IEEE types is provided in separate patches (D113908 <https://reviews.llvm.org/D113908> and D113414 <https://reviews.llvm.org/D113414>). Targets that support FCLASS or similar instruction can have especially efficient implementation, a patch for SystemZ represents an example (D114695 <https://reviews.llvm.org/D114695>). Patches that implement support for this intrinsic in GlobalISel are also published (D121454 <https://reviews.llvm.org/D121454> and D121296 <https://reviews.llvm.org/D121296>).

The patch includes large number of tests. To facilitate validation, a preliminary clang patch was prepared (D112932 <https://reviews.llvm.org/D112932>), which enables runtime testing. Appropriate change for test suite is also provided (D112933 <https://reviews.llvm.org/D112933>). The implementation was tested on X86 and AArch64 hardware and PowerPC emulator.

The intrinsic has evolved to rather generic form and a question may rise if it would be profitable to implement an intrinsic for fpclassify and then use it to implement classification functions. The drawback of the solution based on fpclassify is that this function returns a numeric value which is then exists in runtime. If a target provides instruction FCLASS, it would be convenient to have numerical representation of floating-point classes consistent with the output of FCLASS. Different targets use different layouts for FCLASS output, for example RISC-V, SystemZ and AMDGPU all have such instruction and all use different encoding. It is not possible to use FP class numbering that would be convenient for all targets. There is no such problem for `is_fpclass`. FP class numbers in this case are used in compile-time constants only.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112025/new/

https://reviews.llvm.org/D112025



More information about the llvm-commits mailing list