alpha: Implement FP classification built-in optimizations.
Fixes FP classification on alpha to avoid crashes with subnormal numbers.
GCC expands FP classification built-ins like isnan and isfinite into direct FP comparisons on alpha. These comparisons can trigger exceptions for subnormal operands, leading to program termination. This change replaces these direct comparisons with checks on the floating-point encoding in an integer register, preventing crashes with subnormal values. It also prevents unnecessary rewriting of these built-ins by the compiler.
In Details
The alpha backend previously expanded FP classification built-ins (__builtin_isnan, etc.) into direct FP comparisons. On alpha, these comparisons fail to handle subnormal operands gracefully, leading to a crash. This commit introduces new optabs and expanders in config/alpha/alpha.cc and config/alpha/alpha.md to inspect the FP encoding directly. This avoids the problematic FP comparisons and handles subnormals correctly, aligning with how AArch64 and LoongArch handle similar cases. The change also affects how fold_builtin_interclass_mathfn rewrites these built-ins.
- FP classification built-ins
- Compiler intrinsics like
__builtin_isnan,__builtin_isinf,__builtin_isfinite, and__builtin_isnormalthat determine properties of floating-point numbers. - subnormal operand
- A floating-point number that is too small to be represented in normalized form but not zero. Handling subnormals correctly is crucial for numerical precision and to avoid exceptions.
- optabs
- Optimization tables in GCC that map machine-independent operations to machine-specific code patterns or functions.
- alpha
- The target architecture for this commit, an older RISC instruction set architecture.
- FPCR
- The Floating-Point Control Register, which controls floating-point unit behavior, including exception handling and denormalization modes.