[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 24 09:25:54 PDT 2019
fhahn updated this revision to Diff 196471.
fhahn added a comment.
Generalize patch to handle [a, b) udiv full set == [0, b).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60536/new/
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
@@ -821,6 +821,16 @@
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);
+
+ EXPECT_EQ(ConstantRange(APInt(16, 0), APInt(16, 99)).udiv(Full),
+ ConstantRange(APInt(16, 0), APInt(16, 99)));
+ EXPECT_EQ(ConstantRange(APInt(16, 10), APInt(16, 99)).udiv(Full),
+ ConstantRange(APInt(16, 0), APInt(16, 99)));
}
TEST_F(ConstantRangeTest, URem) {
Index: llvm/lib/IR/ConstantRange.cpp
===================================================================
--- llvm/lib/IR/ConstantRange.cpp
+++ llvm/lib/IR/ConstantRange.cpp
@@ -974,8 +974,6 @@
ConstantRange::udiv(const ConstantRange &RHS) const {
if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isNullValue())
return getEmpty();
- if (RHS.isFullSet())
- return getFull();
APInt Lower = getUnsignedMin().udiv(RHS.getUnsignedMax());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60536.196471.patch
Type: text/x-patch
Size: 1290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190424/5a288f14/attachment.bin>
More information about the llvm-commits
mailing list