[clang] [llvm] [LLVM][APFloat] Add APFloat support for 8-bit UE5M3 type (PR #210720)
Durgadoss R via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 23 05:40:51 PDT 2026
================
@@ -1047,36 +1047,37 @@ TEST(APFloatTest, IsSmallestNormalized) {
continue;
EXPECT_FALSE(APFloat::getZero(Semantics, false).isSmallestNormalized());
- EXPECT_FALSE(APFloat::getZero(Semantics, true).isSmallestNormalized());
+ if (Semantics.hasSignedRepr)
+ EXPECT_FALSE(APFloat::getZero(Semantics, true).isSmallestNormalized());
if (APFloat::semanticsHasNaN(Semantics)) {
// Types that do not support Inf will return NaN when asked for Inf.
// (But only if they support NaN.)
EXPECT_FALSE(APFloat::getInf(Semantics, false).isSmallestNormalized());
- EXPECT_FALSE(APFloat::getInf(Semantics, true).isSmallestNormalized());
+ if (Semantics.hasSignedRepr)
+ EXPECT_FALSE(APFloat::getInf(Semantics, true).isSmallestNormalized());
EXPECT_FALSE(APFloat::getQNaN(Semantics).isSmallestNormalized());
EXPECT_FALSE(APFloat::getSNaN(Semantics).isSmallestNormalized());
}
- EXPECT_FALSE(APFloat::getLargest(Semantics).isSmallestNormalized());
- EXPECT_FALSE(APFloat::getLargest(Semantics, true).isSmallestNormalized());
+ EXPECT_FALSE(APFloat::getLargest(Semantics, false).isSmallestNormalized());
+ if (Semantics.hasSignedRepr)
+ EXPECT_FALSE(APFloat::getLargest(Semantics, true).isSmallestNormalized());
- EXPECT_FALSE(APFloat::getSmallest(Semantics).isSmallestNormalized());
- EXPECT_FALSE(APFloat::getSmallest(Semantics, true).isSmallestNormalized());
+ EXPECT_FALSE(APFloat::getSmallest(Semantics, false).isSmallestNormalized());
+ if (Semantics.hasSignedRepr)
+ EXPECT_FALSE(
+ APFloat::getSmallest(Semantics, true).isSmallestNormalized());
EXPECT_FALSE(APFloat::getAllOnesValue(Semantics).isSmallestNormalized());
APFloat PosSmallestNormalized =
APFloat::getSmallestNormalized(Semantics, false);
- APFloat NegSmallestNormalized =
- APFloat::getSmallestNormalized(Semantics, true);
EXPECT_TRUE(PosSmallestNormalized.isSmallestNormalized());
- EXPECT_TRUE(NegSmallestNormalized.isSmallestNormalized());
EXPECT_EQ(fcPosNormal, PosSmallestNormalized.classify());
- EXPECT_EQ(fcNegNormal, NegSmallestNormalized.classify());
- for (APFloat *Val : {&PosSmallestNormalized, &NegSmallestNormalized}) {
----------------
durga4github wrote:
nit:
would initializing the list with Neg only for SignedRep will reduce the amount of diff here?
something like this:
```
SmallVector<APFloat *> Vals = {&PosSmallestNormalized};
if (Semantics.hasSignedRepr) {
Init - NegSmallestNormalized();
EXPECT_TRUE(NegSmallestNormalized->isSmallestNormalized());
EXPECT_EQ(fcNegNormal, NegSmallestNormalized->classify());
Vals.push_back(&*NegSmallestNormalized);
}
for (APFloat *Val : Vals) {
// original loop body unchanged
}
```
https://github.com/llvm/llvm-project/pull/210720
More information about the cfe-commits
mailing list