[llvm] r304694 - [ConstantRange] Add a few more truncate unittests.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 16:03:54 PDT 2017


Author: ctopper
Date: Sun Jun  4 18:03:54 2017
New Revision: 304694

URL: http://llvm.org/viewvc/llvm-project?rev=304694&view=rev
Log:
[ConstantRange] Add a few more truncate unittests.

Modified:
    llvm/trunk/unittests/IR/ConstantRangeTest.cpp

Modified: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/ConstantRangeTest.cpp?rev=304694&r1=304693&r2=304694&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp (original)
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp Sun Jun  4 18:03:54 2017
@@ -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) {




More information about the llvm-commits mailing list