@@ -561,9 +561,6 @@ TEST(KnownBitsTest, ICmpExhaustive) {
561
561
unsigned Bits = 4 ;
562
562
ForeachKnownBits (Bits, [&](const KnownBits &Known1) {
563
563
ForeachKnownBits (Bits, [&](const KnownBits &Known2) {
564
- if (Known1.hasConflict () || Known2.hasConflict ())
565
- return ;
566
-
567
564
bool AllEQ = true , NoneEQ = true ;
568
565
bool AllNE = true , NoneNE = true ;
569
566
bool AllUGT = true , NoneUGT = true ;
@@ -611,6 +608,9 @@ TEST(KnownBitsTest, ICmpExhaustive) {
611
608
std::optional<bool > KnownSLT = KnownBits::slt (Known1, Known2);
612
609
std::optional<bool > KnownSLE = KnownBits::sle (Known1, Known2);
613
610
611
+ if (Known1.hasConflict () || Known2.hasConflict ())
612
+ return ;
613
+
614
614
EXPECT_EQ (AllEQ || NoneEQ, KnownEQ.has_value ());
615
615
EXPECT_EQ (AllNE || NoneNE, KnownNE.has_value ());
616
616
EXPECT_EQ (AllUGT || NoneUGT, KnownUGT.has_value ());
@@ -650,62 +650,58 @@ TEST(KnownBitsTest, ICmpExhaustive) {
650
650
TEST (KnownBitsTest, GetMinMaxVal) {
651
651
unsigned Bits = 4 ;
652
652
ForeachKnownBits (Bits, [&](const KnownBits &Known) {
653
- if (Known.hasConflict ())
654
- return ;
655
-
656
653
APInt Min = APInt::getMaxValue (Bits);
657
654
APInt Max = APInt::getMinValue (Bits);
658
655
ForeachNumInKnownBits (Known, [&](const APInt &N) {
659
656
Min = APIntOps::umin (Min, N);
660
657
Max = APIntOps::umax (Max, N);
661
658
});
662
- EXPECT_EQ (Min, Known.getMinValue ());
663
- EXPECT_EQ (Max, Known.getMaxValue ());
659
+ if (!Known.hasConflict ()) {
660
+ EXPECT_EQ (Min, Known.getMinValue ());
661
+ EXPECT_EQ (Max, Known.getMaxValue ());
662
+ }
664
663
});
665
664
}
666
665
667
666
TEST (KnownBitsTest, GetSignedMinMaxVal) {
668
667
unsigned Bits = 4 ;
669
668
ForeachKnownBits (Bits, [&](const KnownBits &Known) {
670
- if (Known.hasConflict ())
671
- return ;
672
-
673
669
APInt Min = APInt::getSignedMaxValue (Bits);
674
670
APInt Max = APInt::getSignedMinValue (Bits);
675
671
ForeachNumInKnownBits (Known, [&](const APInt &N) {
676
672
Min = APIntOps::smin (Min, N);
677
673
Max = APIntOps::smax (Max, N);
678
674
});
679
- EXPECT_EQ (Min, Known.getSignedMinValue ());
680
- EXPECT_EQ (Max, Known.getSignedMaxValue ());
675
+ if (!Known.hasConflict ()) {
676
+ EXPECT_EQ (Min, Known.getSignedMinValue ());
677
+ EXPECT_EQ (Max, Known.getSignedMaxValue ());
678
+ }
681
679
});
682
680
}
683
681
684
682
TEST (KnownBitsTest, CountMaxActiveBits) {
685
683
unsigned Bits = 4 ;
686
684
ForeachKnownBits (Bits, [&](const KnownBits &Known) {
687
- if (Known.hasConflict ())
688
- return ;
689
-
690
685
unsigned Expected = 0 ;
691
686
ForeachNumInKnownBits (Known, [&](const APInt &N) {
692
687
Expected = std::max (Expected, N.getActiveBits ());
693
688
});
694
- EXPECT_EQ (Expected, Known.countMaxActiveBits ());
689
+ if (!Known.hasConflict ()) {
690
+ EXPECT_EQ (Expected, Known.countMaxActiveBits ());
691
+ }
695
692
});
696
693
}
697
694
698
695
TEST (KnownBitsTest, CountMaxSignificantBits) {
699
696
unsigned Bits = 4 ;
700
697
ForeachKnownBits (Bits, [&](const KnownBits &Known) {
701
- if (Known.hasConflict ())
702
- return ;
703
-
704
698
unsigned Expected = 0 ;
705
699
ForeachNumInKnownBits (Known, [&](const APInt &N) {
706
700
Expected = std::max (Expected, N.getSignificantBits ());
707
701
});
708
- EXPECT_EQ (Expected, Known.countMaxSignificantBits ());
702
+ if (!Known.hasConflict ()) {
703
+ EXPECT_EQ (Expected, Known.countMaxSignificantBits ());
704
+ }
709
705
});
710
706
}
711
707
@@ -741,9 +737,6 @@ TEST(KnownBitsTest, SExtInReg) {
741
737
unsigned Bits = 4 ;
742
738
for (unsigned FromBits = 1 ; FromBits <= Bits; ++FromBits) {
743
739
ForeachKnownBits (Bits, [&](const KnownBits &Known) {
744
- if (Known.hasConflict ())
745
- return ;
746
-
747
740
APInt CommonOne = APInt::getAllOnes (Bits);
748
741
APInt CommonZero = APInt::getAllOnes (Bits);
749
742
unsigned ExtBits = Bits - FromBits;
@@ -754,8 +747,10 @@ TEST(KnownBitsTest, SExtInReg) {
754
747
CommonZero &= ~Ext;
755
748
});
756
749
KnownBits KnownSExtInReg = Known.sextInReg (FromBits);
757
- EXPECT_EQ (CommonOne, KnownSExtInReg.One );
758
- EXPECT_EQ (CommonZero, KnownSExtInReg.Zero );
750
+ if (!Known.hasConflict ()) {
751
+ EXPECT_EQ (CommonOne, KnownSExtInReg.One );
752
+ EXPECT_EQ (CommonZero, KnownSExtInReg.Zero );
753
+ }
759
754
});
760
755
}
761
756
}
@@ -764,17 +759,16 @@ TEST(KnownBitsTest, CommonBitsSet) {
764
759
unsigned Bits = 4 ;
765
760
ForeachKnownBits (Bits, [&](const KnownBits &Known1) {
766
761
ForeachKnownBits (Bits, [&](const KnownBits &Known2) {
767
- if (Known1.hasConflict () || Known2.hasConflict ())
768
- return ;
769
-
770
762
bool HasCommonBitsSet = false ;
771
763
ForeachNumInKnownBits (Known1, [&](const APInt &N1) {
772
764
ForeachNumInKnownBits (Known2, [&](const APInt &N2) {
773
765
HasCommonBitsSet |= N1.intersects (N2);
774
766
});
775
767
});
776
- EXPECT_EQ (!HasCommonBitsSet,
777
- KnownBits::haveNoCommonBitsSet (Known1, Known2));
768
+ if (!Known1.hasConflict () && !Known2.hasConflict ()) {
769
+ EXPECT_EQ (!HasCommonBitsSet,
770
+ KnownBits::haveNoCommonBitsSet (Known1, Known2));
771
+ }
778
772
});
779
773
});
780
774
}
0 commit comments