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.udiv(One), ConstantRange(APInt(16, 0), in TEST_F()
458 EXPECT_EQ(Full.udiv(Some), ConstantRange(APInt(16, 0), in TEST_F()
465 EXPECT_EQ(One.udiv(One), ConstantRange(APInt(16, 1))); in TEST_F()
466 EXPECT_EQ(One.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 2))); in TEST_F()
467 EXPECT_EQ(One.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xb))); in TEST_F()
468 EXPECT_EQ(Some.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 0x111))); in TEST_F()
469 EXPECT_EQ(Some.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); in TEST_F()
483 EXPECT_EQ(One.shl(One), ConstantRange(APInt(16, 0xa << 0xa), in TEST_F()
495 EXPECT_EQ(Full.lshr(One), ConstantRange(APInt(16, 0), in TEST_F()
497 EXPECT_EQ(Full.lshr(Some), ConstantRange(APInt(16, 0), in TEST_F()
504 EXPECT_EQ(One.lshr(One), ConstantRange(APInt(16, 0))); in TEST_F()
505 EXPECT_EQ(One.lshr(Some), ConstantRange(APInt(16, 0))); in TEST_F()
506 EXPECT_EQ(One.lshr(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xb))); in TEST_F()
507 EXPECT_EQ(Some.lshr(Some), ConstantRange(APInt(16, 0), in TEST_F()
509 EXPECT_EQ(Some.lshr(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); in TEST_F()
513 TEST(ConstantRange, MakeAllowedICmpRegion) { in TEST() argument
515 ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(32)); in TEST()
516 EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGT, SMax) in TEST()
520 TEST(ConstantRange, MakeSatisfyingICmpRegion) { in TEST() argument
521 ConstantRange LowHalf(APInt(8, 0), APInt(8, 128)); in TEST()
522 ConstantRange HighHalf(APInt(8, 128), APInt(8, 0)); in TEST()
523 ConstantRange EmptySet(8, /* isFullSet = */ false); in TEST()
525 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_NE, LowHalf), in TEST()
529 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_NE, HighHalf), in TEST()
532 EXPECT_TRUE(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_EQ, in TEST()
535 ConstantRange UnsignedSample(APInt(8, 5), APInt(8, 200)); in TEST()
537 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_ULT, in TEST()
539 ConstantRange(APInt(8, 0), APInt(8, 5))); in TEST()
541 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_ULE, in TEST()
543 ConstantRange(APInt(8, 0), APInt(8, 6))); in TEST()
545 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_UGT, in TEST()
547 ConstantRange(APInt(8, 200), APInt(8, 0))); in TEST()
549 EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_UGE, in TEST()
551 ConstantRange(APInt(8, 199), APInt(8, 0))); in TEST()
553 ConstantRange SignedSample(APInt(8, -5), APInt(8, 5)); in TEST()
556 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SLT, SignedSample), in TEST()
557 ConstantRange(APInt(8, -128), APInt(8, -5))); in TEST()
560 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SLE, SignedSample), in TEST()
561 ConstantRange(APInt(8, -128), APInt(8, -4))); in TEST()
564 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SGT, SignedSample), in TEST()
565 ConstantRange(APInt(8, 5), APInt(8, -128))); in TEST()
568 ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SGE, SignedSample), in TEST()
569 ConstantRange(APInt(8, 4), APInt(8, -128))); in TEST()
572 TEST(ConstantRange, MakeOverflowingRegion) { in TEST() argument
581 ConstantRange::makeNoWrapRegion(Instruction::Add, C, OBO::NoUnsignedWrap); in TEST()
586 ConstantRange::makeNoWrapRegion(Instruction::Add, C, OBO::NoSignedWrap); in TEST()
590 auto NoWrapRegion = ConstantRange::makeNoWrapRegion( in TEST()