[KnownFPClass] `fpext` and `fptrunc` should use the same shared routine.
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Generally speaking, `fpext` is used when casting to a wider type, and `fptrunc` is used when casting to a narrower type.
However, things are more complicated when casting `x87f80` to `ppcf128`, as different precision, exponent ranges, and value representations come into play. Currently, `ppcf128 = fpext(x87f80_not_infinity)` could return infinity.
I think it would be best if `fpext` and `fptrunc` called the same underlying `fpconvert` or etc routine. This would unify the two similar functions and encourage more generic code that compares the precision, range, and representation of the source and destination types.
This would also allow future proofing for when casting directly from `bfloat` to `ieee_half` and etc is supported.
Contributor guide
Research direction
Start by locating the fpext and fptrunc entry points and comparing how they handle x87f80 and ppcf128 conversions. Define done as routing both operations through one shared conversion routine while preserving precision, exponent-range, and representation behavior, including the non-infinity case described in the issue.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100