Replace use of host floating types with operations on APFloat when it is
possible. Use of APFloat makes analysis more convenient and facilitates
constant folding in the case of non-default FP environment.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
It looks like this is just refactoring, besides the changes to the floating-point compares. That's okay, but not really consistent with the commit message; do you have some future work planned?
llvm/lib/Analysis/ConstantFolding.cpp | ||
---|---|---|
2146–2147 | This isn't precisely equivalent to the existing code. |
llvm/lib/Analysis/ConstantFolding.cpp | ||
---|---|---|
2146–2147 | This handles NaNs differently. |
llvm/lib/Analysis/ConstantFolding.cpp | ||
---|---|---|
2146–2147 | Strictly speaking you are right. Comparison in C is ordered, so V > 0.0 gives false for NaN and ConstantFoldFP` is not called. However all these functions (log* and sqrt*) have specified behavior when their argument is NaN, so the final result must be the same. Other similar functions like sin are called for NaN arguments. |
llvm/lib/Analysis/ConstantFolding.cpp | ||
---|---|---|
2146–2147 | If you want to change this, please add test coverage. |
llvm/lib/Analysis/ConstantFolding.cpp | ||
---|---|---|
2146–2147 | Things are even simpler. The code above contains a check: if (!U.isFinite()) return nullptr; So NaNs cannot reach this code. |
This isn't precisely equivalent to the existing code.