diff options
author | Artur Pilipenko <apilipenko@azulsystems.com> | 2016-10-19 14:44:23 +0000 |
---|---|---|
committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2016-10-19 14:44:23 +0000 |
commit | ed84103a1a3d8f81bd662c89607e274682df56a4 (patch) | |
tree | e999cc6251f3c070b2dacd0055e7cc76a335d3ee /llvm/unittests/IR/ConstantRangeTest.cpp | |
parent | 2cf1dc2add97f1f54b5561e83183d9b140cf422f (diff) | |
download | bcm5719-llvm-ed84103a1a3d8f81bd662c89607e274682df56a4.tar.gz bcm5719-llvm-ed84103a1a3d8f81bd662c89607e274682df56a4.zip |
Introduce ConstantRange.addWithNoSignedWrap
To be used by upcoming change to IndVarSimplify
Reviewed By: sanjoy
Differential Revision: https://reviews.llvm.org/D25732
llvm-svn: 284597
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r-- | llvm/unittests/IR/ConstantRangeTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp index b890a4a0bc4..58fd04448e2 100644 --- a/llvm/unittests/IR/ConstantRangeTest.cpp +++ b/llvm/unittests/IR/ConstantRangeTest.cpp @@ -357,6 +357,32 @@ TEST_F(ConstantRangeTest, Add) { ConstantRange(APInt(16, 0xe))); } +TEST_F(ConstantRangeTest, AddWithNoSignedWrap) { + EXPECT_EQ(Empty.addWithNoSignedWrap(APInt(16, 1)), Empty); + EXPECT_EQ(Full.addWithNoSignedWrap(APInt(16, 1)), + ConstantRange(APInt(16, INT16_MIN+1), APInt(16, INT16_MIN))); + EXPECT_EQ(ConstantRange(APInt(8, -50), APInt(8, 50)).addWithNoSignedWrap(APInt(8, 10)), + ConstantRange(APInt(8, -40), APInt(8, 60))); + EXPECT_EQ(ConstantRange(APInt(8, -50), APInt(8, 120)).addWithNoSignedWrap(APInt(8, 10)), + ConstantRange(APInt(8, -40), APInt(8, INT8_MIN))); + EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -10)).addWithNoSignedWrap(APInt(8, 5)), + ConstantRange(APInt(8, 125), APInt(8, -5))); + EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -120)).addWithNoSignedWrap(APInt(8, 10)), + ConstantRange(APInt(8, INT8_MIN+10), APInt(8, -110))); + + EXPECT_EQ(Empty.addWithNoSignedWrap(APInt(16, -1)), Empty); + EXPECT_EQ(Full.addWithNoSignedWrap(APInt(16, -1)), + ConstantRange(APInt(16, INT16_MIN), APInt(16, INT16_MAX))); + EXPECT_EQ(ConstantRange(APInt(8, -50), APInt(8, 50)).addWithNoSignedWrap(APInt(8, -10)), + ConstantRange(APInt(8, -60), APInt(8, 40))); + EXPECT_EQ(ConstantRange(APInt(8, -120), APInt(8, 50)).addWithNoSignedWrap(APInt(8, -10)), + ConstantRange(APInt(8, INT8_MIN), APInt(8, 40))); + EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -120)).addWithNoSignedWrap(APInt(8, -5)), + ConstantRange(APInt(8, 115), APInt(8, -125))); + EXPECT_EQ(ConstantRange(APInt(8, 120), APInt(8, -120)).addWithNoSignedWrap(APInt(8, -10)), + ConstantRange(APInt(8, 110), APInt(8, INT8_MIN-10))); +} + TEST_F(ConstantRangeTest, Sub) { EXPECT_EQ(Full.sub(APInt(16, 4)), Full); EXPECT_EQ(Full.sub(Full), Full); |