[llvm-dev] [cfe-dev] Should isnan be optimized out in fast-math mode?
Serge Pavlov via llvm-dev
llvm-dev at lists.llvm.org
Wed Sep 15 22:37:23 PDT 2021
Let me make some summary. I omit references for brevity, they are spread in
the thread.
Treatment of `isnan` with `-ffinite-math-only` has issues:
- There are many users' complaints and disagreement expressed in GCC bug
tracker and forums about the treatment.
- There are legitimate use cases when `isnan` needs to be called in
`-ffinite-math-only` mode.
- Users have to invent workarounds to get functionality of `isnan`, which
results in portability and performance loss.
- There is inconsistency with the behavior of libc, which always does a
real check, and the compiler, which omits it.
Preserving `isnan` in the code would solve all of them.
What is the risk?
`-ffinite-math-only` is an optimization option, so preserving `isnan`
cannot break the behavior of correct programs. The only possible negative
impact is some loss of performance. It is unlikely that a real program
spends so much time in `isnan` calls that it has noticeable effect, but if
it does, a user can conditionally redefine `isnan` macro.
Preserving `isnan` in `-ffinite-math-only` mode is safe and makes the
compiler more reliable and user-friendly.
Thanks,
--Serge
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210916/99e16ec1/attachment.html>
More information about the llvm-dev
mailing list