[KnownFPClass] `log(DoubleDouble)` is incorrectly assumed to be never subnormal
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`KnownFPClass::log` always rules out the result being subnormal. For common floating point types, `log(x)` will never be subnormal `log(1 + 2^-52) ≈ 2^-52 = normal`. However, the DoubleDouble type can represent `log(1 + 2^-1074) ≈ 2^-1074 = subnormal`.
https://github.com/llvm/llvm-project/blob/87c22715f1c42d38e4071802448c2f56b6b6fa34/llvm/lib/Support/KnownFPClass.cpp#L544-L547
Proposed solution:
Add a `IsMultiUnitFPType` parameter similar to `KnownFPClass::roundToIntegral`.
***
The deduction that `sqrt`, `cbrt`, `acos`, and `acosh` are never subnormal is still valid for the DoubleDouble type.
To my understanding, we would also need to look out for this issue when implementing these `` functions in the future:
- `lgamma(1.0 +-DBL_TRUE_MIN)` and `lgamma(2.0 +-DBL_TRUE_MIN)` prevent ruling out negative zero and subnormal for DoubleDouble.
- A non-subnormal input to `sinpi`, `cospi`, and `tanpi` can be subnormal for the DoubleDouble type.
- `compoundn(-1.0 + DBL_TRUE_MIN, 1) = pow(DBL_TRUE_MIN, 1) = DBL_TRUE_MIN`
Contributor guide
Research direction
Read llvm/lib/Support/KnownFPClass.cpp around lines 544-547 and inspect the existing KnownFPClass::roundToIntegral handling for IsMultiUnitFPType. Confirm how log currently rules out subnormal results, then update that deduction for DoubleDouble while preserving the valid deductions for sqrt, cbrt, acos, and acosh.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100