[PATCH] D104854: Introduce intrinsic llvm.isnan

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 24 10:01:33 PDT 2021


sepavloff added a comment.

In D104854#2838754 <https://reviews.llvm.org/D104854#2838754>, @craig.topper wrote:

> Doesn't gcc also fold isnan to false under fast math? If we diverge here that means your code would only work correctly with clang.

GCC does the same transformation, ICC and MSVC do not: https://godbolt.org/z/ovboWqPeb. Both clang and GCC do this transformation only with optimization level > 0. With -O0 both produce code that does real check, so semantic of the produced code is different depending on optimization level, it looks more like a bug rather than feature.

There is a GCC ticket: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84949, which refers to the similar thing. It is created against to libstdc++ but the reason is in the compiler. In one on the comments there (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84949#c8) an opinion is expressed:

  ... My conclusion: std::numeric_limits means "has NaN bitpattern" and "has IEC559 bit layout" not "has NaNs with NaN behavior" and "has IEC559 behavior".

So this behavior is considered as incorrect.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854



More information about the cfe-commits mailing list