mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-01 12:43:47 +00:00
[libc] Make log2f correctly rounded for all rounding modes when FMA is not available.
Add to log2f 2 more exceptional cases got when not using fma for polyeval. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D117812
This commit is contained in:
parent
5ef7abbc6f
commit
1f3f90ab88
@ -105,11 +105,24 @@ LLVM_LIBC_FUNCTION(float, log2f, (float x)) {
|
||||
int m = 0;
|
||||
|
||||
// Hard to round value(s).
|
||||
if (FPBits(x).uintval() == 0x3f81d0b5U) {
|
||||
switch (FPBits(x).uintval()) {
|
||||
case 0x3f81d0b5U: {
|
||||
int rounding_mode = fputil::get_round();
|
||||
if (rounding_mode == FE_DOWNWARD || rounding_mode == FE_TOWARDZERO) {
|
||||
return 0x1.4cdc4cp-6f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x3f7e3274U:
|
||||
if (fputil::get_round() == FE_TONEAREST) {
|
||||
return -0x1.4e1d16p-7f;
|
||||
}
|
||||
break;
|
||||
case 0x3f7d57f5U:
|
||||
if (fputil::get_round() == FE_TOWARDZERO) {
|
||||
return -0x1.ed1c32p-7f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Exceptional inputs.
|
||||
|
@ -31,10 +31,10 @@ TEST(LlvmLibcLog2fTest, SpecialNumbers) {
|
||||
}
|
||||
|
||||
TEST(LlvmLibcLog2fTest, TrickyInputs) {
|
||||
constexpr int N = 9;
|
||||
constexpr uint32_t INPUTS[N] = {0x3f7d57f5U, 0x3f7ed848U, 0x3f7fd6ccU,
|
||||
0x3f7fffffU, 0x3f80079bU, 0x3f81d0b5U,
|
||||
0x3f82e602U, 0x3f83c98dU, 0x3f8cba39U};
|
||||
constexpr int N = 10;
|
||||
constexpr uint32_t INPUTS[N] = {
|
||||
0x3f7d57f5U, 0x3f7e3274U, 0x3f7ed848U, 0x3f7fd6ccU, 0x3f7fffffU,
|
||||
0x3f80079bU, 0x3f81d0b5U, 0x3f82e602U, 0x3f83c98dU, 0x3f8cba39U};
|
||||
|
||||
for (int i = 0; i < N; ++i) {
|
||||
float x = float(FPBits(INPUTS[i]));
|
||||
|
Loading…
x
Reference in New Issue
Block a user