[PATCH] D155394: [clang][Interp] Implement __builtin_fpclassify

Joshua Cranmer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 12:45:51 PDT 2023


jcranmer-intel added inline comments.


================
Comment at: clang/test/AST/Interp/builtin-functions.cpp:121-130
+  char classify_nan     [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))];
+  char classify_snan    [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))];
+  char classify_inf     [__builtin_fpclassify(-1, +1, -1, -1, -1, __builtin_inf())];
+  char classify_neg_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, -__builtin_inf())];
+  char classify_normal  [__builtin_fpclassify(-1, -1, +1, -1, -1, 1.539)];
+  char classify_normal2 [__builtin_fpclassify(-1, -1, +1, -1, -1, 1e-307)];
+  char classify_denorm  [__builtin_fpclassify(-1, -1, -1, +1, -1, 1e-308)];
----------------
aaron.ballman wrote:
> One thing we should test is that promotion does not happen on the final argument (converting it from `float` to `double`) -- @jcranmer-intel can you think of a good way to test that in this case?
A subnormal `float` would be a normal `double`, so using `1.0e-38f` should classify as a denormal and not a normal numal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155394



More information about the cfe-commits mailing list