Lines Matching refs:ConstantRange
21 static ConstantRange Full;
22 static ConstantRange Empty;
23 static ConstantRange One;
24 static ConstantRange Some;
25 static ConstantRange Wrap;
28 ConstantRange ConstantRangeTest::Full(16);
29 ConstantRange ConstantRangeTest::Empty(16, false);
30 ConstantRange ConstantRangeTest::One(APInt(16, 0xa));
31 ConstantRange ConstantRangeTest::Some(APInt(16, 0xa), APInt(16, 0xaaa));
32 ConstantRange ConstantRangeTest::Wrap(APInt(16, 0xaaa), APInt(16, 0xa));
122 ConstantRange Wrap(APInt(4, 7), APInt(4, 3)); in TEST_F()
123 ConstantRange Wrap2(APInt(4, 8), APInt(4, 7)); in TEST_F()
150 EXPECT_EQ(ConstantRange(APInt(4, 7), APInt(4, 0)).getSignedMax(), in TEST_F()
161 EXPECT_FALSE(ConstantRange(APInt(8, 127), APInt(8, 128)).isSignWrappedSet()); in TEST_F()
162 EXPECT_TRUE(ConstantRange(APInt(8, 127), APInt(8, 129)).isSignWrappedSet()); in TEST_F()
163 EXPECT_FALSE(ConstantRange(APInt(8, 128), APInt(8, 129)).isSignWrappedSet()); in TEST_F()
164 EXPECT_TRUE(ConstantRange(APInt(8, 10), APInt(8, 9)).isSignWrappedSet()); in TEST_F()
165 EXPECT_TRUE(ConstantRange(APInt(8, 10), APInt(8, 250)).isSignWrappedSet()); in TEST_F()
166 EXPECT_FALSE(ConstantRange(APInt(8, 250), APInt(8, 10)).isSignWrappedSet()); in TEST_F()
167 EXPECT_FALSE(ConstantRange(APInt(8, 250), APInt(8, 251)).isSignWrappedSet()); in TEST_F()
171 ConstantRange TFull = Full.truncate(10); in TEST_F()
172 ConstantRange TEmpty = Empty.truncate(10); in TEST_F()
173 ConstantRange TOne = One.truncate(10); in TEST_F()
174 ConstantRange TSome = Some.truncate(10); in TEST_F()
175 ConstantRange TWrap = Wrap.truncate(10); in TEST_F()
178 EXPECT_EQ(TOne, ConstantRange(One.getLower().trunc(10), in TEST_F()
184 ConstantRange ZFull = Full.zeroExtend(20); in TEST_F()
185 ConstantRange ZEmpty = Empty.zeroExtend(20); in TEST_F()
186 ConstantRange ZOne = One.zeroExtend(20); in TEST_F()
187 ConstantRange ZSome = Some.zeroExtend(20); in TEST_F()
188 ConstantRange ZWrap = Wrap.zeroExtend(20); in TEST_F()
189 EXPECT_EQ(ZFull, ConstantRange(APInt(20, 0), APInt(20, 0x10000))); in TEST_F()
191 EXPECT_EQ(ZOne, ConstantRange(One.getLower().zext(20), in TEST_F()
193 EXPECT_EQ(ZSome, ConstantRange(Some.getLower().zext(20), in TEST_F()
195 EXPECT_EQ(ZWrap, ConstantRange(APInt(20, 0), APInt(20, 0x10000))); in TEST_F()
198 ConstantRange FiveZero(APInt(3, 5), APInt(3, 0)); in TEST_F()
199 EXPECT_EQ(FiveZero.zeroExtend(7), ConstantRange(APInt(7, 5), APInt(7, 8))); in TEST_F()
203 ConstantRange SFull = Full.signExtend(20); in TEST_F()
204 ConstantRange SEmpty = Empty.signExtend(20); in TEST_F()
205 ConstantRange SOne = One.signExtend(20); in TEST_F()
206 ConstantRange SSome = Some.signExtend(20); in TEST_F()
207 ConstantRange SWrap = Wrap.signExtend(20); in TEST_F()
208 EXPECT_EQ(SFull, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true), in TEST_F()
211 EXPECT_EQ(SOne, ConstantRange(One.getLower().sext(20), in TEST_F()
213 EXPECT_EQ(SSome, ConstantRange(Some.getLower().sext(20), in TEST_F()
215 EXPECT_EQ(SWrap, ConstantRange(APInt(20, (uint64_t)INT16_MIN, true), in TEST_F()
218 EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, 140)).signExtend(16), in TEST_F()
219 ConstantRange(APInt(16, -128), APInt(16, 128))); in TEST_F()
221 EXPECT_EQ(ConstantRange(APInt(16, 0x0200), APInt(16, 0x8000)).signExtend(19), in TEST_F()
222 ConstantRange(APInt(19, 0x0200), APInt(19, 0x8000))); in TEST_F()
243 ConstantRange LHS(APInt(16, 4), APInt(16, 2)); in TEST_F()
244 ConstantRange RHS(APInt(16, 6), APInt(16, 5)); in TEST_F()
248 LHS = ConstantRange(APInt(32, -2147483646), APInt(32, 3)); in TEST_F()
249 RHS = ConstantRange(APInt(32, 2), APInt(32, 2147483646)); in TEST_F()
250 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 2))); in TEST_F()
253 LHS = ConstantRange(APInt(32, 2), APInt(32, 0)); in TEST_F()
254 RHS = ConstantRange(APInt(32, 4), APInt(32, 3)); in TEST_F()
255 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 2), APInt(32, 0))); in TEST_F()
258 LHS = ConstantRange(APInt(32, 2), APInt(32, 0)); in TEST_F()
259 RHS = ConstantRange(APInt(32, 4), APInt(32, 2)); in TEST_F()
260 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 4), APInt(32, 0))); in TEST_F()
263 LHS = ConstantRange(APInt(32, 4), APInt(32, 2)); in TEST_F()
264 RHS = ConstantRange(APInt(32, 5), APInt(32, 1)); in TEST_F()
265 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 5), APInt(32, 1))); in TEST_F()
268 LHS = ConstantRange(APInt(32, 2), APInt(32, 0)); in TEST_F()
269 RHS = ConstantRange(APInt(32, 7), APInt(32, 4)); in TEST_F()
270 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 7), APInt(32, 4))); in TEST_F()
273 LHS = ConstantRange(APInt(32, 4), APInt(32, 2)); in TEST_F()
274 RHS = ConstantRange(APInt(32, 1), APInt(32, 0)); in TEST_F()
275 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 4), APInt(32, 2))); in TEST_F()
278 LHS = ConstantRange(APInt(32, 15), APInt(32, 0)); in TEST_F()
279 RHS = ConstantRange(APInt(32, 7), APInt(32, 6)); in TEST_F()
280 EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 15), APInt(32, 0))); in TEST_F()
285 ConstantRange(APInt(16, 0xaaa), APInt(16, 0xb))); in TEST_F()
292 EXPECT_EQ(ConstantRange(APInt(16, 14), APInt(16, 1)).unionWith( in TEST_F()
293 ConstantRange(APInt(16, 0), APInt(16, 8))), in TEST_F()
294 ConstantRange(APInt(16, 14), APInt(16, 8))); in TEST_F()
295 EXPECT_EQ(ConstantRange(APInt(16, 6), APInt(16, 4)).unionWith( in TEST_F()
296 ConstantRange(APInt(16, 4), APInt(16, 0))), in TEST_F()
297 ConstantRange(16)); in TEST_F()
298 EXPECT_EQ(ConstantRange(APInt(16, 1), APInt(16, 0)).unionWith( in TEST_F()
299 ConstantRange(APInt(16, 2), APInt(16, 1))), in TEST_F()
300 ConstantRange(16)); in TEST_F()
309 ConstantRange A(APInt(16, 3), APInt(16, 7)); in TEST_F()
310 ConstantRange B(APInt(16, 5), APInt(16, 9)); in TEST_F()
311 ConstantRange C(APInt(16, 3), APInt(16, 5)); in TEST_F()
312 ConstantRange D(APInt(16, 7), APInt(16, 9)); in TEST_F()
313 ConstantRange E(APInt(16, 5), APInt(16, 4)); in TEST_F()
314 ConstantRange F(APInt(16, 7), APInt(16, 3)); in TEST_F()
324 ConstantRange(APInt(16, 0x6), APInt(16, 0xaa6))); in TEST_F()
326 ConstantRange(APInt(16, 0xaa6), APInt(16, 0x6))); in TEST_F()
328 ConstantRange(APInt(16, 0x6))); in TEST_F()
344 ConstantRange(APInt(16, 0xe), APInt(16, 0xaae))); in TEST_F()
346 ConstantRange(APInt(16, 0xaae), APInt(16, 0xe))); in TEST_F()
348 ConstantRange(APInt(16, 0xe))); in TEST_F()
364 ConstantRange(APInt(16, 0x6), APInt(16, 0xaa6))); in TEST_F()
366 ConstantRange(APInt(16, 0xf561), APInt(16, 0xaa0))); in TEST_F()
368 ConstantRange(APInt(16, 0xaa6), APInt(16, 0x6))); in TEST_F()
370 ConstantRange(APInt(16, 0x6))); in TEST_F()
383 EXPECT_EQ(One.multiply(One), ConstantRange(APInt(16, 0xa*0xa), in TEST_F()
385 EXPECT_EQ(One.multiply(Some), ConstantRange(APInt(16, 0xa*0xa), in TEST_F()
392 ConstantRange Zero(APInt(16, 0)); in TEST_F()
401 EXPECT_EQ(ConstantRange(APInt(4, 1), APInt(4, 6)).multiply( in TEST_F()
402 ConstantRange(APInt(4, 6), APInt(4, 2))), in TEST_F()
403 ConstantRange(4, /*isFullSet=*/true)); in TEST_F()
405 EXPECT_EQ(ConstantRange(APInt(8, 254), APInt(8, 0)).multiply( in TEST_F()
406 ConstantRange(APInt(8, 252), APInt(8, 4))), in TEST_F()
407 ConstantRange(APInt(8, 250), APInt(8, 9))); in TEST_F()
408 EXPECT_EQ(ConstantRange(APInt(8, 254), APInt(8, 255)).multiply( in TEST_F()
409 ConstantRange(APInt(8, 2), APInt(8, 4))), in TEST_F()
410 ConstantRange(APInt(8, 250), APInt(8, 253))); in TEST_F()
416 EXPECT_EQ(Full.umax(Some), ConstantRange(APInt(16, 0xa), APInt(16, 0))); in TEST_F()
418 EXPECT_EQ(Full.umax(Some), ConstantRange(APInt(16, 0xa), APInt(16, 0))); in TEST_F()
424 EXPECT_EQ(Some.umax(Wrap), ConstantRange(APInt(16, 0xa), APInt(16, 0))); in TEST_F()
428 EXPECT_EQ(Wrap.umax(One), ConstantRange(APInt(16, 0xa), APInt(16, 0))); in TEST_F()
435 EXPECT_EQ(Full.smax(Some), ConstantRange(APInt(16, 0xa), in TEST_F()
438 EXPECT_EQ(Full.smax(One), ConstantRange(APInt(16, 0xa), in TEST_F()
445 EXPECT_EQ(Some.smax(Wrap), ConstantRange(APInt(16, 0xa), in TEST_F()
448 EXPECT_EQ(Wrap.smax(One), ConstantRange(APInt(16, 0xa), in TEST_F()
456 EXPECT_EQ(Full.umin(Some), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); in TEST_F()
463 EXPECT_EQ(Some.umin(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); in TEST_F()
467 EXPECT_EQ(Wrap.umin(One), ConstantRange(APInt(16, 0), APInt(16, 0xb))); in TEST_F()
474 EXPECT_EQ(Full.smin(Some), ConstantRange(APInt(16, (uint64_t)INT16_MIN), in TEST_F()
482 EXPECT_EQ(Some.smin(Wrap), ConstantRange(APInt(16, (uint64_t)INT16_MIN), in TEST_F()
487 EXPECT_EQ(Wrap.smin(One), ConstantRange(APInt(16, (uint64_t)INT16_MIN), in TEST_F()
495 EXPECT_EQ(Full.udiv(One), ConstantRange(APInt(16, 0), in TEST_F()
497 EXPECT_EQ(Full.udiv(Some), ConstantRange(APInt(16, 0), in TEST_F()
504 EXPECT_EQ(One.udiv(One), ConstantRange(APInt(16, 1))); in TEST_F()
505 EXPECT_EQ(One.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 2))); in TEST_F()
506 EXPECT_EQ(One.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xb))); in TEST_F()
507 EXPECT_EQ(Some.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 0x111))); in TEST_F()
508 EXPECT_EQ(Some.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); in TEST_F()
522 EXPECT_EQ(One.shl(One), ConstantRange(APInt(16, 0xa << 0xa), in TEST_F()
534 EXPECT_EQ(Full.lshr(One), ConstantRange(APInt(16, 0), in TEST_F()
536 EXPECT_EQ(Full.lshr(Some), ConstantRange(APInt(16, 0), in TEST_F()
543 EXPECT_EQ(One.lshr(One), ConstantRange(APInt(16, 0))); in TEST_F()
544 EXPECT_EQ(One.lshr(Some), ConstantRange(APInt(16, 0))); in TEST_F()
545 EXPECT_EQ(One.lshr(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xb))); in TEST_F()
546 EXPECT_EQ(Some.lshr(Some), ConstantRange(APInt(16, 0), in TEST_F()
548 EXPECT_EQ(Some.lshr(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); in TEST_F()
552 TEST(ConstantRange, MakeAllowedICmpRegion) { in TEST() argument
554 ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(32)); in TEST()
555 EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGT, SMax) in TEST()
559 TEST(ConstantRange, MakeSatisfyingICmpRegion) { in TEST() argument
560 ConstantRange LowHalf(APInt(8, 0), APInt(8, 128)); in TEST()
561 ConstantRange HighHalf(APInt(8, 128), APInt(8, 0)); in TEST()
562 ConstantRange EmptySet(8, /* isFullSet = */ false); in TEST()
564 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_NE, LowHalf), in TEST()
568 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_NE, HighHalf), in TEST()
571 EXPECT_TRUE(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_EQ, in TEST()
574 ConstantRange UnsignedSample(APInt(8, 5), APInt(8, 200)); in TEST()
576 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_ULT, in TEST()
578 ConstantRange(APInt(8, 0), APInt(8, 5))); in TEST()
580 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_ULE, in TEST()
582 ConstantRange(APInt(8, 0), APInt(8, 6))); in TEST()
584 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_UGT, in TEST()
586 ConstantRange(APInt(8, 200), APInt(8, 0))); in TEST()
588 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_UGE, in TEST()
590 ConstantRange(APInt(8, 199), APInt(8, 0))); in TEST()
592 ConstantRange SignedSample(APInt(8, -5), APInt(8, 5)); in TEST()
595 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SLT, SignedSample), in TEST()
596 ConstantRange(APInt(8, -128), APInt(8, -5))); in TEST()
599 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SLE, SignedSample), in TEST()
600 ConstantRange(APInt(8, -128), APInt(8, -4))); in TEST()
603 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SGT, SignedSample), in TEST()
604 ConstantRange(APInt(8, 5), APInt(8, -128))); in TEST()
607 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SGE, SignedSample), in TEST()
608 ConstantRange(APInt(8, 4), APInt(8, -128))); in TEST()
611 TEST(ConstantRange, MakeGuaranteedNoWrapRegion) { in TEST() argument
619 auto NUWRegion = ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
624 auto NSWRegion = ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
629 auto NoWrapRegion = ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
661 auto NSWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
662 Instruction::Add, ConstantRange(32, /* isFullSet = */ true), in TEST()
667 auto NUWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
668 Instruction::Add, ConstantRange(32, /* isFullSet = */ true), in TEST()
673 auto NUWAndNSWForAllValues = ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
674 Instruction::Add, ConstantRange(32, /* isFullSet = */ true), in TEST()
679 ConstantRange OneToFive(APInt(32, 1), APInt(32, 6)); in TEST()
680 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
682 ConstantRange(APInt::getSignedMinValue(32), in TEST()
684 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
686 ConstantRange(APInt::getMinValue(32), APInt::getMinValue(32) - 5)); in TEST()
688 ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
690 ConstantRange(APInt::getMinValue(32), APInt::getSignedMaxValue(32) - 4)); in TEST()
692 ConstantRange MinusFiveToMinusTwo(APInt(32, -5), APInt(32, -1)); in TEST()
693 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
695 ConstantRange(APInt::getSignedMinValue(32) + 5, in TEST()
697 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
699 ConstantRange(APInt(32, 0), APInt(32, 2))); in TEST()
700 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
703 ConstantRange(APInt(32, 0), APInt(32, 2))); in TEST()
705 ConstantRange MinusOneToOne(APInt(32, -1), APInt(32, 2)); in TEST()
706 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
708 ConstantRange(APInt::getSignedMinValue(32) + 1, in TEST()
710 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
712 ConstantRange(APInt(32, 0), APInt(32, 1))); in TEST()
713 EXPECT_EQ(ConstantRange::makeGuaranteedNoWrapRegion( in TEST()
716 ConstantRange(APInt(32, 0), APInt(32, 1))); in TEST()
719 TEST(ConstantRange, GetEquivalentICmp) { in TEST() argument
723 EXPECT_TRUE(ConstantRange(APInt::getMinValue(32), APInt(32, 100)) in TEST()
728 EXPECT_TRUE(ConstantRange(APInt::getSignedMinValue(32), APInt(32, 100)) in TEST()
733 EXPECT_TRUE(ConstantRange(APInt(32, 100), APInt::getMinValue(32)) in TEST()
738 EXPECT_TRUE(ConstantRange(APInt(32, 100), APInt::getSignedMinValue(32)) in TEST()
744 ConstantRange(32, /*isFullSet=*/true).getEquivalentICmp(Pred, RHS)); in TEST()
749 ConstantRange(32, /*isFullSet=*/false).getEquivalentICmp(Pred, RHS)); in TEST()
753 EXPECT_FALSE(ConstantRange(APInt(32, 100), APInt(32, 200)) in TEST()
756 EXPECT_FALSE(ConstantRange(APInt::getSignedMinValue(32) - APInt(32, 100), in TEST()
760 EXPECT_FALSE(ConstantRange(APInt::getMinValue(32) - APInt(32, 100), in TEST()