diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-07-19 03:44:35 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-07-19 03:44:35 +0000 |
commit | 567daf3ce8ee278893b4065cfb13feae8d2c82a4 (patch) | |
tree | 737e23bcd0b62315eb76bc5e36248557d1f9fe33 /llvm/unittests/Support/ConstantRangeTest.cpp | |
parent | 461ea7f005698357d9e3170bdbdab47c78449426 (diff) | |
download | bcm5719-llvm-567daf3ce8ee278893b4065cfb13feae8d2c82a4.tar.gz bcm5719-llvm-567daf3ce8ee278893b4065cfb13feae8d2c82a4.zip |
Fix ConstantRange::unionWith. Also make it work a little hard in some cases to
return the smallest union of two ranges instead of just any range that happens
to contain the union.
llvm-svn: 76360
Diffstat (limited to 'llvm/unittests/Support/ConstantRangeTest.cpp')
-rw-r--r-- | llvm/unittests/Support/ConstantRangeTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ConstantRangeTest.cpp b/llvm/unittests/Support/ConstantRangeTest.cpp index b77ac6aece0..b1b82a99273 100644 --- a/llvm/unittests/Support/ConstantRangeTest.cpp +++ b/llvm/unittests/Support/ConstantRangeTest.cpp @@ -219,6 +219,17 @@ TEST_F(ConstantRangeTest, UnionWith) { EXPECT_TRUE(Empty.unionWith(Empty).isEmptySet()); EXPECT_TRUE(Full.unionWith(Full).isFullSet()); EXPECT_TRUE(Some.unionWith(Wrap).isFullSet()); + + // PR4545 + EXPECT_EQ(ConstantRange(APInt(16, 14), APInt(16, 1)).unionWith( + ConstantRange(APInt(16, 0), APInt(16, 8))), + ConstantRange(APInt(16, 14), APInt(16, 8))); + EXPECT_EQ(ConstantRange(APInt(16, 6), APInt(16, 4)).unionWith( + ConstantRange(APInt(16, 4), APInt(16, 0))), + ConstantRange(16)); + EXPECT_EQ(ConstantRange(APInt(16, 1), APInt(16, 0)).unionWith( + ConstantRange(APInt(16, 2), APInt(16, 1))), + ConstantRange(16)); } TEST_F(ConstantRangeTest, SubtractAPInt) { |