Skip to content

Commit db4874c

Browse files
authored
[ConstantFPRange][UnitTests] Guard exhaustive checks by EXPENSIVE_CHECKS (#111276)
Addresses comment #111056 (comment).
1 parent 6568827 commit db4874c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

llvm/unittests/IR/ConstantFPRangeTest.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ TEST_F(ConstantFPRangeTest, FPClassify) {
435435
EXPECT_EQ(SomePos.getSignBit(), false);
436436
EXPECT_EQ(SomeNeg.getSignBit(), true);
437437

438+
#if defined(EXPENSIVE_CHECKS)
438439
EnumerateConstantFPRanges(
439440
[](const ConstantFPRange &CR) {
440441
unsigned Mask = fcNone;
@@ -458,6 +459,7 @@ TEST_F(ConstantFPRangeTest, FPClassify) {
458459
EXPECT_EQ(Mask, CR.classify()) << CR;
459460
},
460461
/*Exhaustive=*/true);
462+
#endif
461463
}
462464

463465
TEST_F(ConstantFPRangeTest, Print) {
@@ -500,6 +502,36 @@ TEST_F(ConstantFPRangeTest, MismatchedSemantics) {
500502
#endif
501503

502504
TEST_F(ConstantFPRangeTest, makeAllowedFCmpRegion) {
505+
EXPECT_EQ(ConstantFPRange::makeAllowedFCmpRegion(
506+
FCmpInst::FCMP_OLE,
507+
ConstantFPRange::getNonNaN(APFloat(1.0), APFloat(2.0))),
508+
ConstantFPRange::getNonNaN(APFloat::getInf(Sem, /*Negative=*/true),
509+
APFloat(2.0)));
510+
EXPECT_EQ(
511+
ConstantFPRange::makeAllowedFCmpRegion(
512+
FCmpInst::FCMP_OLT,
513+
ConstantFPRange::getNonNaN(APFloat(1.0),
514+
APFloat::getInf(Sem, /*Negative=*/false))),
515+
ConstantFPRange::getNonNaN(APFloat::getInf(Sem, /*Negative=*/true),
516+
APFloat::getLargest(Sem, /*Negative=*/false)));
517+
EXPECT_EQ(
518+
ConstantFPRange::makeAllowedFCmpRegion(
519+
FCmpInst::FCMP_OGT,
520+
ConstantFPRange::getNonNaN(APFloat::getZero(Sem, /*Negative=*/true),
521+
APFloat(2.0))),
522+
ConstantFPRange::getNonNaN(APFloat::getSmallest(Sem, /*Negative=*/false),
523+
APFloat::getInf(Sem, /*Negative=*/false)));
524+
EXPECT_EQ(ConstantFPRange::makeAllowedFCmpRegion(
525+
FCmpInst::FCMP_OGE,
526+
ConstantFPRange::getNonNaN(APFloat(1.0), APFloat(2.0))),
527+
ConstantFPRange::getNonNaN(
528+
APFloat(1.0), APFloat::getInf(Sem, /*Negative=*/false)));
529+
EXPECT_EQ(ConstantFPRange::makeAllowedFCmpRegion(
530+
FCmpInst::FCMP_OEQ,
531+
ConstantFPRange::getNonNaN(APFloat(1.0), APFloat(2.0))),
532+
ConstantFPRange::getNonNaN(APFloat(1.0), APFloat(2.0)));
533+
534+
#if defined(EXPENSIVE_CHECKS)
503535
for (auto Pred : FCmpInst::predicates()) {
504536
EnumerateConstantFPRanges(
505537
[Pred](const ConstantFPRange &CR) {
@@ -529,6 +561,7 @@ TEST_F(ConstantFPRangeTest, makeAllowedFCmpRegion) {
529561
},
530562
/*Exhaustive=*/false);
531563
}
564+
#endif
532565
}
533566

534567
} // anonymous namespace

0 commit comments

Comments
 (0)