@@ -651,11 +651,13 @@ static void TestAddWithNoSignedWrapExhaustive(Fn1 RangeFn, Fn2 IntFn) {
651
651
ConstantRange CR = RangeFn (CR1, CR2);
652
652
APInt Min = APInt::getSignedMaxValue (Bits);
653
653
APInt Max = APInt::getSignedMinValue (Bits);
654
+ bool AllOverflow = true ;
654
655
ForeachNumInConstantRange (CR1, [&](const APInt &N1) {
655
656
ForeachNumInConstantRange (CR2, [&](const APInt &N2) {
656
657
bool IsOverflow = false ;
657
658
APInt N = IntFn (IsOverflow, N1, N2);
658
659
if (!IsOverflow) {
660
+ AllOverflow = false ;
659
661
if (N.slt (Min))
660
662
Min = N;
661
663
if (N.sgt (Max))
@@ -664,6 +666,9 @@ static void TestAddWithNoSignedWrapExhaustive(Fn1 RangeFn, Fn2 IntFn) {
664
666
}
665
667
});
666
668
});
669
+
670
+ EXPECT_EQ (CR.isEmptySet (), AllOverflow);
671
+
667
672
if (!CR1.isSignWrappedSet () && !CR2.isSignWrappedSet ()) {
668
673
if (Min.sgt (Max)) {
669
674
EXPECT_TRUE (CR.isEmptySet ());
@@ -684,11 +689,13 @@ static void TestAddWithNoUnsignedWrapExhaustive(Fn1 RangeFn, Fn2 IntFn) {
684
689
ConstantRange CR = RangeFn (CR1, CR2);
685
690
APInt Min = APInt::getMaxValue (Bits);
686
691
APInt Max = APInt::getMinValue (Bits);
692
+ bool AllOverflow = true ;
687
693
ForeachNumInConstantRange (CR1, [&](const APInt &N1) {
688
694
ForeachNumInConstantRange (CR2, [&](const APInt &N2) {
689
695
bool IsOverflow = false ;
690
696
APInt N = IntFn (IsOverflow, N1, N2);
691
697
if (!IsOverflow) {
698
+ AllOverflow = false ;
692
699
if (N.ult (Min))
693
700
Min = N;
694
701
if (N.ugt (Max))
@@ -698,6 +705,8 @@ static void TestAddWithNoUnsignedWrapExhaustive(Fn1 RangeFn, Fn2 IntFn) {
698
705
});
699
706
});
700
707
708
+ EXPECT_EQ (CR.isEmptySet (), AllOverflow);
709
+
701
710
if (!CR1.isWrappedSet () && !CR2.isWrappedSet ()) {
702
711
if (Min.ugt (Max)) {
703
712
EXPECT_TRUE (CR.isEmptySet ());
@@ -722,12 +731,14 @@ static void TestAddWithNoSignedUnsignedWrapExhaustive(Fn1 RangeFn,
722
731
APInt UMax = APInt::getMinValue (Bits);
723
732
APInt SMin = APInt::getSignedMaxValue (Bits);
724
733
APInt SMax = APInt::getSignedMinValue (Bits);
734
+ bool AllOverflow = true ;
725
735
ForeachNumInConstantRange (CR1, [&](const APInt &N1) {
726
736
ForeachNumInConstantRange (CR2, [&](const APInt &N2) {
727
737
bool IsOverflow = false , IsSignedOverflow = false ;
728
738
APInt N = IntFnSigned (IsSignedOverflow, N1, N2);
729
739
(void ) IntFnUnsigned (IsOverflow, N1, N2);
730
740
if (!IsSignedOverflow && !IsOverflow) {
741
+ AllOverflow = false ;
731
742
if (N.slt (SMin))
732
743
SMin = N;
733
744
if (N.sgt (SMax))
@@ -741,6 +752,8 @@ static void TestAddWithNoSignedUnsignedWrapExhaustive(Fn1 RangeFn,
741
752
});
742
753
});
743
754
755
+ EXPECT_EQ (CR.isEmptySet (), AllOverflow);
756
+
744
757
if (!CR1.isWrappedSet () && !CR2.isWrappedSet () &&
745
758
!CR1.isSignWrappedSet () && !CR2.isSignWrappedSet ()) {
746
759
if (UMin.ugt (UMax) || SMin.sgt (SMax)) {
0 commit comments