[PATCH] D136568: [Clang] Support constexpr builtin ilogb

Joshua Cranmer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 13:13:15 PDT 2022


jcranmer-intel added inline comments.


================
Comment at: clang/test/Sema/constant-builtins-ilogb.cpp:53-63
+// assert smallest subnormal and largest finite numbers
+static_assert(__builtin_ilogbf(1.40129846E-45f) == -149);
+static_assert(__builtin_ilogbf(3.40282347E+38f) == 127);
+
+static_assert(__builtin_ilogb(4.9406564584124654E-324) == -1074);
+static_assert(__builtin_ilogb(1.7976931348623157E+308) == 1023);
+
----------------
You can simplify at least the float, double, and especially long double tests using something like this:

```
static_assert(__builtin_ilogbf(__FLT_MIN__) == __FLT_MIN_EXP__ + 1);
static_assert(__builtin_ilogbf(__FLT_MAX__) == __FLT_MAX_EXP__ - 1);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136568



More information about the cfe-commits mailing list