[KnownFPClass] Support rounding-modes for `fadd`/`fsub`/`fmul`/`fdiv`/`fma`/`fmuladd` and `ldexp`
Currently, fadd/fsub/fmul/fdiv/fma/fmuladd (and ldexp) assume round-to-nearest with ties-to-even. We also support experimental_constrained_* versions of these operations which take a rounding mode, so it would probably be good to add a rounding mode parameter for these primitive IEEE operations. frem is always exact and does not need a rounding mode.
The easiest way to implement the rounding-mode for each function would be:
- Implement the function assuming
RoundingMode::Dynamic. It is possible that we may add aRoundingMode::AwayZero(not the same asRoundingMode::NearestTiesToAway) rounding mode in the future, so we should assume thatRoundingMode::Dynamicalso containsRoundingMode::AwayZero. - Then add back in deductions specific to
RoundingMode::NearestTiesToEven(e.g. ruling out-0.0forfadd(x, +0.0))
Afterwards, we can add specific deductions for a particular rounding mode. For example, ruling out +0.0 for fadd(x, -0.0) under RoundingMode::TowardNegative.
experimental_constrained_sqrt is already handled in ValueTracking.cpp, so adding support for the experimental_constrained_* intrinsics shouldn't be too difficult.
https://github.com/llvm/llvm-project/blob/9f70ca880b37eba68a171f36272e06d8d2d371f3/llvm/lib/Analysis/ValueTracking.cpp#L5463-L5464
Progress
- [x] Support
experimental_constrained_fadd/experimental_constrained_fsubhttps://github.com/llvm/llvm-project/pull/241060 - [ ] Support
experimental_constrained_fmul - [ ] Support
experimental_constrained_fdiv - [x] Support
experimental_constrained_fremhttps://github.com/llvm/llvm-project/pull/239882 - [ ] Support
experimental_constrained_fma - [ ] Support
experimental_constrained_fmuladd - [ ] Support
experimental_constrained_ldexp
hey, i would like to work on this
hey, i would like to work on this
I am sorry, but I have already started working on this issue.