[libc-commits] [libc] [libc][math] Update BFloat16 basic operation exhaustive tests to include mixed signs. (PR #182131)
via libc-commits
libc-commits at lists.llvm.org
Wed Feb 18 12:48:04 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (lntue)
<details>
<summary>Changes</summary>
https://github.com/llvm/llvm-project/issues/181121
---
Full diff: https://github.com/llvm/llvm-project/pull/182131.diff
4 Files Affected:
- (modified) libc/test/src/math/exhaustive/bfloat16_add_test.cpp (+9-1)
- (modified) libc/test/src/math/exhaustive/bfloat16_div_test.cpp (+9-1)
- (modified) libc/test/src/math/exhaustive/bfloat16_mul_test.cpp (+9-1)
- (modified) libc/test/src/math/exhaustive/bfloat16_sub_test.cpp (+9-1)
``````````diff
diff --git a/libc/test/src/math/exhaustive/bfloat16_add_test.cpp b/libc/test/src/math/exhaustive/bfloat16_add_test.cpp
index 3f4c77978a93d..c523badeb7e8a 100644
--- a/libc/test/src/math/exhaustive/bfloat16_add_test.cpp
+++ b/libc/test/src/math/exhaustive/bfloat16_add_test.cpp
@@ -32,7 +32,7 @@ struct Bfloat16AddChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint64_t failed = 0;
do {
BFloat16 x = FPBits(xbits).get_val();
- uint16_t ybits = xbits;
+ uint16_t ybits = y_start;
do {
BFloat16 y = FPBits(ybits).get_val();
mpfr::BinaryInput<BFloat16> input{x, y};
@@ -63,3 +63,11 @@ TEST_F(LlvmLibcBfloat16ExhaustiveAddTest, PositiveRange) {
TEST_F(LlvmLibcBfloat16ExhaustiveAddTest, NegativeRange) {
test_full_range_all_roundings(NEG_START, NEG_STOP, NEG_START, NEG_STOP);
}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveAddTest, PositiveNegative) {
+ test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
+}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveAddTest, NegativePositive) {
+ test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
+}
diff --git a/libc/test/src/math/exhaustive/bfloat16_div_test.cpp b/libc/test/src/math/exhaustive/bfloat16_div_test.cpp
index 2648d5f775af5..fa614db206f96 100644
--- a/libc/test/src/math/exhaustive/bfloat16_div_test.cpp
+++ b/libc/test/src/math/exhaustive/bfloat16_div_test.cpp
@@ -32,7 +32,7 @@ struct Bfloat16DivChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint64_t failed = 0;
do {
BFloat16 x = FPBits(xbits).get_val();
- uint16_t ybits = xbits;
+ uint16_t ybits = y_start;
do {
BFloat16 y = FPBits(ybits).get_val();
mpfr::BinaryInput<BFloat16> input{x, y};
@@ -63,3 +63,11 @@ TEST_F(LlvmLibcBfloat16ExhaustiveDivTest, PositiveRange) {
TEST_F(LlvmLibcBfloat16ExhaustiveDivTest, NegativeRange) {
test_full_range_all_roundings(NEG_START, NEG_STOP, NEG_START, NEG_STOP);
}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveDivTest, PositiveNegative) {
+ test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
+}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveDivTest, NegativePositive) {
+ test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
+}
diff --git a/libc/test/src/math/exhaustive/bfloat16_mul_test.cpp b/libc/test/src/math/exhaustive/bfloat16_mul_test.cpp
index 3cbbcb500a4fb..d827401f4ce76 100644
--- a/libc/test/src/math/exhaustive/bfloat16_mul_test.cpp
+++ b/libc/test/src/math/exhaustive/bfloat16_mul_test.cpp
@@ -32,7 +32,7 @@ struct Bfloat16MulChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint64_t failed = 0;
do {
BFloat16 x = FPBits(xbits).get_val();
- uint16_t ybits = xbits;
+ uint16_t ybits = y_start;
do {
BFloat16 y = FPBits(ybits).get_val();
mpfr::BinaryInput<BFloat16> input{x, y};
@@ -63,3 +63,11 @@ TEST_F(LlvmLibcBfloat16ExhaustiveMulTest, PositiveRange) {
TEST_F(LlvmLibcBfloat16ExhaustiveMulTest, NegativeRange) {
test_full_range_all_roundings(NEG_START, NEG_STOP, NEG_START, NEG_STOP);
}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveMulTest, PositiveNegative) {
+ test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
+}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveMulTest, NegativePositive) {
+ test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
+}
diff --git a/libc/test/src/math/exhaustive/bfloat16_sub_test.cpp b/libc/test/src/math/exhaustive/bfloat16_sub_test.cpp
index 11bc6f59dd294..2109ee957abbe 100644
--- a/libc/test/src/math/exhaustive/bfloat16_sub_test.cpp
+++ b/libc/test/src/math/exhaustive/bfloat16_sub_test.cpp
@@ -32,7 +32,7 @@ struct Bfloat16SubChecker : public virtual LIBC_NAMESPACE::testing::Test {
uint64_t failed = 0;
do {
BFloat16 x = FPBits(xbits).get_val();
- uint16_t ybits = xbits;
+ uint16_t ybits = y_start;
do {
BFloat16 y = FPBits(ybits).get_val();
mpfr::BinaryInput<BFloat16> input{x, y};
@@ -63,3 +63,11 @@ TEST_F(LlvmLibcBfloat16ExhaustiveSubTest, PositiveRange) {
TEST_F(LlvmLibcBfloat16ExhaustiveSubTest, NegativeRange) {
test_full_range_all_roundings(NEG_START, NEG_STOP, NEG_START, NEG_STOP);
}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveSubTest, PositiveNegative) {
+ test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
+}
+
+TEST_F(LlvmLibcBfloat16ExhaustiveSubTest, NegativePositive) {
+ test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/182131
More information about the libc-commits
mailing list