[X86] Implement llvm.isnan(x86_fp80) as unordered comparison
authorSerge Pavlov <sepavloff@gmail.com>
Fri, 13 Aug 2021 09:52:29 +0000 (16:52 +0700)
committerSerge Pavlov <sepavloff@gmail.com>
Fri, 27 Aug 2021 11:06:07 +0000 (18:06 +0700)
commitcdbe569fb6cd34e83b695485bfc5786d54b89017
tree454adc5c91ab3734e427b4c653758318b0ba8ab2
parent199ac3a839d900a5274da019c0dca41aac61cf2c
[X86] Implement llvm.isnan(x86_fp80) as unordered comparison

x86_fp80 format allows values that do not fit any of IEEE-754 category.
Previously they were recognized by intrinsic __builtin_isnan as NaNs.
Now this intrinsic is implemented using instruction FXAM, which
distinguish between NaNs and unsupported values. It can make some
programs behave differently.

As a solution, this fix changes lowering of the intrinsic. If floating
point exceptions are ignored, llvm.isnan is lowered into unordered
comparison, as __buildtin_isnan was implemented earlier. In strictfp
functions the intrinsic is lowered using FXAM, which does not raise
exceptions even for signaling NaN, as required by IEEE-754 and C
standards.

Differential Revision: https://reviews.llvm.org/D108037
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/x86-fpclass.ll