diff options
author | Nikita Popov <npopov@redhat.com> | 2022-07-01 15:43:27 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-07-01 15:44:59 +0200 |
commit | ba1e04b9668b3502362f2ee36232f5f56e72b4e2 (patch) | |
tree | 83e1124f5acb76b877f878b3d8222b39c1a5a2b4 /llvm/unittests/IR/ConstantRangeTest.cpp | |
parent | 5166345f50412f1a380948c18809545c4b7a9bd3 (diff) | |
download | llvm-ba1e04b9668b3502362f2ee36232f5f56e72b4e2.zip llvm-ba1e04b9668b3502362f2ee36232f5f56e72b4e2.tar.gz llvm-ba1e04b9668b3502362f2ee36232f5f56e72b4e2.tar.bz2 |
[ConstantRange] Fix sdiv() with one bit values (PR56333)
Signed one bit values can only be -1 or 0, not positive. The code
was interpreting the 1 as -1 and intersecting with a full range
rather than an empty one.
Fixes https://github.com/llvm/llvm-project/issues/56333.
Diffstat (limited to 'llvm/unittests/IR/ConstantRangeTest.cpp')
-rw-r--r-- | llvm/unittests/IR/ConstantRangeTest.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp index ced38a2..edea097 100644 --- a/llvm/unittests/IR/ConstantRangeTest.cpp +++ b/llvm/unittests/IR/ConstantRangeTest.cpp @@ -1259,6 +1259,9 @@ TEST_F(ConstantRangeTest, UDiv) { } TEST_F(ConstantRangeTest, SDiv) { + ConstantRange OneBit = ConstantRange::getFull(1); + EXPECT_EQ(OneBit.sdiv(OneBit), ConstantRange(APInt(1, 0))); + unsigned Bits = 4; EnumerateTwoConstantRanges(Bits, [&](const ConstantRange &CR1, const ConstantRange &CR2) { |