@@ -565,6 +565,40 @@ TEST_F(ConstantFPRangeTest, makeAllowedFCmpRegion) {
565
565
}
566
566
567
567
TEST_F (ConstantFPRangeTest, makeSatisfyingFCmpRegion) {
568
+ EXPECT_EQ (ConstantFPRange::makeSatisfyingFCmpRegion (
569
+ FCmpInst::FCMP_OLE,
570
+ ConstantFPRange::getNonNaN (APFloat (1.0 ), APFloat (2.0 ))),
571
+ ConstantFPRange::getNonNaN (APFloat::getInf (Sem, /* Negative=*/ true ),
572
+ APFloat (1.0 )));
573
+ EXPECT_EQ (
574
+ ConstantFPRange::makeSatisfyingFCmpRegion (
575
+ FCmpInst::FCMP_OLT, ConstantFPRange::getNonNaN (
576
+ APFloat::getSmallest (Sem, /* Negative=*/ false ),
577
+ APFloat::getInf (Sem, /* Negative=*/ false ))),
578
+ ConstantFPRange::getNonNaN (APFloat::getInf (Sem, /* Negative=*/ true ),
579
+ APFloat::getZero (Sem, /* Negative=*/ false )));
580
+ EXPECT_EQ (
581
+ ConstantFPRange::makeSatisfyingFCmpRegion (
582
+ FCmpInst::FCMP_OGT, ConstantFPRange::getNonNaN (
583
+ APFloat::getZero (Sem, /* Negative=*/ true ),
584
+ APFloat::getZero (Sem, /* Negative=*/ false ))),
585
+ ConstantFPRange::getNonNaN (APFloat::getSmallest (Sem, /* Negative=*/ false ),
586
+ APFloat::getInf (Sem, /* Negative=*/ false )));
587
+ EXPECT_EQ (ConstantFPRange::makeSatisfyingFCmpRegion (
588
+ FCmpInst::FCMP_OGE,
589
+ ConstantFPRange::getNonNaN (APFloat (1.0 ), APFloat (2.0 ))),
590
+ ConstantFPRange::getNonNaN (
591
+ APFloat (2.0 ), APFloat::getInf (Sem, /* Negative=*/ false )));
592
+ EXPECT_EQ (ConstantFPRange::makeSatisfyingFCmpRegion (
593
+ FCmpInst::FCMP_OEQ,
594
+ ConstantFPRange::getNonNaN (APFloat (1.0 ), APFloat (2.0 ))),
595
+ ConstantFPRange::getEmpty (Sem));
596
+ EXPECT_EQ (ConstantFPRange::makeSatisfyingFCmpRegion (
597
+ FCmpInst::FCMP_OEQ,
598
+ ConstantFPRange::getNonNaN (APFloat (1.0 ), APFloat (1.0 ))),
599
+ ConstantFPRange::getNonNaN (APFloat (1.0 ), APFloat (1.0 )));
600
+
601
+ #if defined(EXPENSIVE_CHECKS)
568
602
for (auto Pred : FCmpInst::predicates ()) {
569
603
EnumerateConstantFPRanges (
570
604
[Pred](const ConstantFPRange &CR) {
@@ -578,9 +612,12 @@ TEST_F(ConstantFPRangeTest, makeSatisfyingFCmpRegion) {
578
612
EnumerateValuesInConstantFPRange (
579
613
ConstantFPRange::getFull (CR.getSemantics ()),
580
614
[&](const APFloat &V) {
581
- if (AnyOfValueInConstantFPRange (CR, [&](const APFloat &U) {
582
- return !FCmpInst::compare (V, U, Pred);
583
- })) {
615
+ if (AnyOfValueInConstantFPRange (
616
+ CR,
617
+ [&](const APFloat &U) {
618
+ return !FCmpInst::compare (V, U, Pred);
619
+ },
620
+ /* IgnoreNaNPayload=*/ true )) {
584
621
EXPECT_FALSE (Res.contains (V))
585
622
<< " Wrong result for makeSatisfyingFCmpRegion(" << Pred
586
623
<< " , " << CR << " ). The result " << Res
@@ -596,7 +633,8 @@ TEST_F(ConstantFPRangeTest, makeSatisfyingFCmpRegion) {
596
633
++NonNaNValsInOptimalSet;
597
634
}
598
635
}
599
- });
636
+ },
637
+ /* IgnoreNaNPayload=*/ true );
600
638
601
639
// Check optimality
602
640
@@ -615,10 +653,13 @@ TEST_F(ConstantFPRangeTest, makeSatisfyingFCmpRegion) {
615
653
// We only care about the cases where the result is representable by
616
654
// ConstantFPRange.
617
655
unsigned NonNaNValsInSuperSet = 0 ;
618
- EnumerateValuesInConstantFPRange (SuperSet, [&](const APFloat &V) {
619
- if (!V.isNaN ())
620
- ++NonNaNValsInSuperSet;
621
- });
656
+ EnumerateValuesInConstantFPRange (
657
+ SuperSet,
658
+ [&](const APFloat &V) {
659
+ if (!V.isNaN ())
660
+ ++NonNaNValsInSuperSet;
661
+ },
662
+ /* IgnoreNaNPayload=*/ true );
622
663
623
664
if (NonNaNValsInSuperSet == NonNaNValsInOptimalSet) {
624
665
ConstantFPRange Optimal =
@@ -631,6 +672,7 @@ TEST_F(ConstantFPRangeTest, makeSatisfyingFCmpRegion) {
631
672
},
632
673
/* Exhaustive=*/ false );
633
674
}
675
+ #endif
634
676
}
635
677
636
678
TEST_F (ConstantFPRangeTest, fcmp) {
@@ -682,12 +724,19 @@ TEST_F(ConstantFPRangeTest, fcmp) {
682
724
for (auto &RHS : InterestingRanges) {
683
725
for (auto Pred : FCmpInst::predicates ()) {
684
726
if (LHS.fcmp (Pred, RHS)) {
685
- EnumerateValuesInConstantFPRange (LHS, [&](const APFloat &LHSC) {
686
- EnumerateValuesInConstantFPRange (RHS, [&](const APFloat &RHSC) {
687
- EXPECT_TRUE (FCmpInst::compare (LHSC, RHSC, Pred))
688
- << LHS << " " << Pred << " " << RHS << " doesn't hold" ;
689
- });
690
- });
727
+ EnumerateValuesInConstantFPRange (
728
+ LHS,
729
+ [&](const APFloat &LHSC) {
730
+ EnumerateValuesInConstantFPRange (
731
+ RHS,
732
+ [&](const APFloat &RHSC) {
733
+ EXPECT_TRUE (FCmpInst::compare (LHSC, RHSC, Pred))
734
+ << LHS << " " << Pred << " " << RHS
735
+ << " doesn't hold" ;
736
+ },
737
+ /* IgnoreNaNPayload=*/ true );
738
+ },
739
+ /* IgnoreNaNPayload=*/ true );
691
740
}
692
741
}
693
742
}
0 commit comments