Skip to content

Commit 13dd3ff

Browse files
committed
fix powf16 tests
1 parent 28d52f6 commit 13dd3ff

File tree

1 file changed

+4
-30
lines changed

1 file changed

+4
-30
lines changed

libc/test/src/math/powf16_test.cpp

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,8 @@ TEST_F(LlvmLibcPowF16Test, SelectedX_AllY) {
2828
float16 y = FPBits(y_u).get_val();
2929

3030
mpfr::BinaryInput<float16> input{x, y};
31-
float16 result = LIBC_NAMESPACE::powf16(x, y);
32-
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Pow, input, result, 1.0);
33-
34-
// If the result is infinity and we expect it to continue growing, we can
35-
// terminate the loop early.
36-
if (FPBits(result).is_inf() && FPBits(result).is_pos()) {
37-
// For x > 1, as y increases in the positive range, pow remains inf.
38-
if (x > static_cast<float16>(1.0f) && y > static_cast<float16>(0.0f)) {
39-
// The y_u loop covers the positive range up to 0x7BFF.
40-
break;
41-
}
42-
// For 0 < x < 1, as y becomes more negative, pow becomes inf.
43-
if (x > static_cast<float16>(0.0f) && x < static_cast<float16>(1.0f) &&
44-
y < static_cast<float16>(0.0f)) {
45-
// The y_u loop covers the negative range from 0x8000.
46-
break;
47-
}
48-
}
31+
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Pow, input,
32+
LIBC_NAMESPACE::powf16(x, y), 0.5);
4933
}
5034
}
5135
}
@@ -58,18 +42,8 @@ TEST_F(LlvmLibcPowF16Test, SelectedY_AllX) {
5842
for (uint16_t x_u = 0; x_u <= 0x7c00U; ++x_u) {
5943
float16 x = FPBits(x_u).get_val();
6044
mpfr::BinaryInput<float16> input{x, y};
61-
float16 result = LIBC_NAMESPACE::powf16(x, y);
62-
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Pow, input, result, 1.0);
63-
64-
// If the result is infinity and we expect it to continue growing, we can
65-
// terminate the loop early.
66-
if (FPBits(result).is_inf() && FPBits(result).is_pos()) {
67-
// For y > 0, as x increases in the positive range, pow remains inf.
68-
if (y > 0.0f16 && x > 0.0f16) {
69-
// The x_u loop covers the positive range up to 0x7BFF.
70-
break;
71-
}
72-
}
45+
EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Pow, input,
46+
LIBC_NAMESPACE::powf16(x, y), 0.5);
7347
}
7448
}
7549
}

0 commit comments

Comments
 (0)