Izaron added a comment.

This patch is similar to `__bultin_fmax`: https://reviews.llvm.org/D134369
The constexpr version of ilogb matches the libc realization, this is verified 
with the same tests:
https://github.com/llvm/llvm-project/blob/main/libc/test/src/math/ILogbTest.h

  test_special_numbers -> ILOGB_TEST_SPECIAL_NUMBERS
  test_powers_of_two -> ILOGB_TEST_POWERS_OF_TWO
  test_some_integers -> ILOGB_TEST_SOME_INTEGERS

https://eel.is/c++draft/library.c#3 says that a floating-point exception other 
than `FE_INEXACT` causes it to not be a constant expression.
I check it with small `ilog` function refactoring and the new function 
`isConstantOpStatus`.

The online documentation (https://en.cppreference.com/w/cpp/numeric/math/ilogb) 
says:

  1. If the correct result is greater than INT_MAX or smaller than INT_MIN, 
FE_INVALID is raised.
  2. If arg is ±0, ±∞, or NaN, FE_INVALID is raised.
  3. In all other cases, the result is exact (FE_INEXACT is never raised) and 
the current rounding mode is ignored

The first point seemingly never occur, because llvm's `ilogb` return type is 
`int`.
The second point is handled as expected (`APFloatTest.cpp` checks it)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136568

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to