summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-11-08 10:24:46 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2019-11-08 10:31:04 +0300
commite0ea842baec00b6bf6dc0069f1c1961da5889927 (patch)
treebe01b4cfe945279b071b24e0fb52e5fcfcc296fc /llvm/unittests/IR
parent6b8baf3062cdc7bd88867e239f26b6966ee3142c (diff)
downloadbcm5719-llvm-e0ea842baec00b6bf6dc0069f1c1961da5889927.tar.gz
bcm5719-llvm-e0ea842baec00b6bf6dc0069f1c1961da5889927.zip
[ConstantRange] Add `ushl_sat()`/`sshl_sat()` methods.
Summary: To be used in `ConstantRange::shlWithNoOverflow()`, may in future be useful for when saturating shift/mul ops are added. Unlike `ConstantRange::shl()`, these are precise. Reviewers: nikic, spatel, reames Reviewed By: nikic Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69960
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r--llvm/unittests/IR/ConstantRangeTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index 4bc620f3ce8..7440574cee4 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -2217,6 +2217,14 @@ TEST_F(ConstantRangeTest, USubSat) {
});
}
+TEST_F(ConstantRangeTest, UShlSat) {
+ TestUnsignedBinOpExhaustive(
+ [](const ConstantRange &CR1, const ConstantRange &CR2) {
+ return CR1.ushl_sat(CR2);
+ },
+ [](const APInt &N1, const APInt &N2) { return N1.ushl_sat(N2); });
+}
+
TEST_F(ConstantRangeTest, SAddSat) {
TestSignedBinOpExhaustive(
[](const ConstantRange &CR1, const ConstantRange &CR2) {
@@ -2237,6 +2245,14 @@ TEST_F(ConstantRangeTest, SSubSat) {
});
}
+TEST_F(ConstantRangeTest, SShlSat) {
+ TestSignedBinOpExhaustive(
+ [](const ConstantRange &CR1, const ConstantRange &CR2) {
+ return CR1.sshl_sat(CR2);
+ },
+ [](const APInt &N1, const APInt &N2) { return N1.sshl_sat(N2); });
+}
+
TEST_F(ConstantRangeTest, Abs) {
unsigned Bits = 4;
EnumerateConstantRanges(Bits, [&](const ConstantRange &CR) {
OpenPOWER on IntegriCloud