[libc-commits] [libc] 0ef0d6c - [libc][math] Update BFloat16 basic operation exhaustive tests to include mixed signs. (#182131)
via libc-commits
libc-commits at lists.llvm.org
Wed Feb 18 13:58:40 PST 2026
Author: lntue
Date: 2026-02-18T16:58:35-05:00
New Revision: 0ef0d6c8d7acce10edb1457485e33441d5cc23f5
URL: https://github.com/llvm/llvm-project/commit/0ef0d6c8d7acce10edb1457485e33441d5cc23f5
DIFF: https://github.com/llvm/llvm-project/commit/0ef0d6c8d7acce10edb1457485e33441d5cc23f5.diff
LOG: [libc][math] Update BFloat16 basic operation exhaustive tests to include mixed signs. (#182131)
https://github.com/llvm/llvm-project/issues/181121
Added:
Modified:
libc/test/src/math/exhaustive/bfloat16_add_test.cpp
libc/test/src/math/exhaustive/bfloat16_div_test.cpp
libc/test/src/math/exhaustive/bfloat16_mul_test.cpp
libc/test/src/math/exhaustive/bfloat16_sub_test.cpp
Removed:
################################################################################
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);
+}
More information about the libc-commits
mailing list