[PATCH] D60536: [ConstantRange] [0, 1) divided by non-empty ranges is [0, 1).
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 13:03:09 PDT 2019
fhahn created this revision.
fhahn added reviewers: nikic, spatel, efriedma.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60536
Files:
llvm/lib/IR/ConstantRange.cpp
llvm/unittests/IR/ConstantRangeTest.cpp
Index: llvm/unittests/IR/ConstantRangeTest.cpp
===================================================================
--- llvm/unittests/IR/ConstantRangeTest.cpp
+++ llvm/unittests/IR/ConstantRangeTest.cpp
@@ -770,6 +770,10 @@
EXPECT_EQ(Some.udiv(Some), ConstantRange(APInt(16, 0), APInt(16, 0x111)));
EXPECT_EQ(Some.udiv(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa)));
EXPECT_EQ(Wrap.udiv(Wrap), Full);
+
+ ConstantRange Zero(APInt(16, 0));
+ EXPECT_EQ(Zero.udiv(One), Zero);
+ EXPECT_EQ(Zero.udiv(Full), Zero);
}
TEST_F(ConstantRangeTest, Shl) {
Index: llvm/lib/IR/ConstantRange.cpp
===================================================================
--- llvm/lib/IR/ConstantRange.cpp
+++ llvm/lib/IR/ConstantRange.cpp
@@ -1009,6 +1009,8 @@
ConstantRange::udiv(const ConstantRange &RHS) const {
if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isNullValue())
return getEmpty();
+ if (isSingleElement() && getSingleElement()->isNullValue())
+ return *this;
if (RHS.isFullSet())
return getFull();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60536.194577.patch
Type: text/x-patch
Size: 1052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190410/bdbe534a/attachment.bin>
More information about the llvm-commits
mailing list