From 014d3cb804cecfba5f4a6b3cd9da22fcab47596f Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 4 Jun 2017 23:03:54 +0000 Subject: [PATCH] [ConstantRange] Add a few more truncate unittests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304694 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/IR/ConstantRangeTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/unittests/IR/ConstantRangeTest.cpp b/unittests/IR/ConstantRangeTest.cpp index a03b7680d29..c6a0ef8f1b7 100644 --- a/unittests/IR/ConstantRangeTest.cpp +++ b/unittests/IR/ConstantRangeTest.cpp @@ -188,6 +188,18 @@ TEST_F(ConstantRangeTest, Trunc) { One.getUpper().trunc(10))); EXPECT_TRUE(TSome.isFullSet()); EXPECT_TRUE(TWrap.isFullSet()); + + // trunc([2, 5), 3->2) = [2, 1) + ConstantRange TwoFive(APInt(3, 2), APInt(3, 5)); + EXPECT_EQ(TwoFive.truncate(2), ConstantRange(APInt(2, 2), APInt(2, 1))); + + // trunc([2, 6), 3->2) = full + ConstantRange TwoSix(APInt(3, 2), APInt(3, 6)); + EXPECT_TRUE(TwoSix.truncate(2).isFullSet()); + + // trunc([5, 7), 3->2) = [1, 3) + ConstantRange FiveSeven(APInt(3, 5), APInt(3, 7)); + EXPECT_EQ(FiveSeven.truncate(2), ConstantRange(APInt(2, 1), APInt(2, 3))); } TEST_F(ConstantRangeTest, ZExt) { -- 2.50.1