[PATCH] D134136: [Clang] Support constexpr for builtin fmax, fmin, ilogb, logb, scalbn
Evgeny Shulgin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 18 07:36:18 PDT 2022
Izaron added inline comments.
================
Comment at: clang/test/Sema/constant-builtins-math.cpp:16-17
+
+// TODO: investigate why this is `INT_MIN + 1` instead of `INT_MIN`
+static_assert(__builtin_ilogb(0.0) == -2147483647);
+static_assert(__builtin_ilogb(__builtin_inf()) == 2147483647);
----------------
Izaron wrote:
> runtime version of `__builtin_ilogb/std::ilogb` returns `INT_MIN` (`-2147483647`) on this argument, while constexpr version returns `INT_MIN+1` 🤔
>
> This constant is here:
> https://llvm.org/doxygen/APFloat_8cpp_source.html#l04187
> https://llvm.org/doxygen/APFloat_8h_source.html#l00229
> (I guess we shouldn't change this)
quick fix: `INT_MIN` is `-2147483648`, `INT_MIN+1` is `2147483647`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134136/new/
https://reviews.llvm.org/D134136
More information about the cfe-commits
mailing list