[PATCH] D145150: clang: Emit nofpclass(nan inf) for -ffinite-math-only

Joshua Cranmer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 2 07:48:54 PST 2023


jcranmer-intel added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2212
+static llvm::FPClassTest getNoFPClassTestMask(const LangOptions &LangOpts) {
+  // TODO: Handle -fno-signaling-nans
+  llvm::FPClassTest Mask = llvm::fcNone;
----------------
Clang doesn't have support for -f[no-]signaling-nans yet, but the gcc documentation for the option states:

> Compile code assuming that IEEE signaling NaNs may generate user-visible traps during floating-point operations.  Setting this option disables optimizations that may change the number of exceptions visible with signaling NaNs.  This option implies -ftrapping-math.

This strikes me as saying that sNaNs are treated as qNaN (akin to the `nsz` fast-math flag) rather than saying that it's UB to have `sNaN` as a value, thus, I don't think it makes sense for -fno-signaling-nans to translate into a `nofpclass` attribute.


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

https://reviews.llvm.org/D145150



More information about the cfe-commits mailing list