summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2010-09-07 05:39:02 +0000
committerNick Lewycky <nicholas@mxc.ca>2010-09-07 05:39:02 +0000
commit198381e542320265e1c5fed18e938db3563a45bf (patch)
treea98f4c5d152f298a16df53c579b2225cc3a729b5 /lib/Support
parent2b6c01b40b75e363e46b3ad7c598113eb98f34fb (diff)
downloadllvm-198381e542320265e1c5fed18e938db3563a45bf.tar.gz
llvm-198381e542320265e1c5fed18e938db3563a45bf.tar.bz2
llvm-198381e542320265e1c5fed18e938db3563a45bf.tar.xz
Add completely hokey binary-and and binary-or operations to ConstantRange and
teach LazyValueInfo to use them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113196 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/ConstantRange.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp
index defb8189b6..c89ec9a2aa 100644
--- a/lib/Support/ConstantRange.cpp
+++ b/lib/Support/ConstantRange.cpp
@@ -608,6 +608,32 @@ ConstantRange::udiv(const ConstantRange &RHS) const {
}
ConstantRange
+ConstantRange::binaryAnd(const ConstantRange &Other) const {
+ if (isEmptySet() || Other.isEmptySet())
+ return ConstantRange(getBitWidth(), /*isFullSet=*/false);
+
+ // TODO: replace this with something less conservative
+
+ APInt umin = APIntOps::umin(Other.getUnsignedMax(), getUnsignedMax());
+ if (umin.isAllOnesValue())
+ return ConstantRange(getBitWidth(), /*isFullSet=*/true);
+ return ConstantRange(APInt::getNullValue(getBitWidth()), umin + 1);
+}
+
+ConstantRange
+ConstantRange::binaryOr(const ConstantRange &Other) const {
+ if (isEmptySet() || Other.isEmptySet())
+ return ConstantRange(getBitWidth(), /*isFullSet=*/false);
+
+ // TODO: replace this with something less conservative
+
+ APInt umax = APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin());
+ if (umax.isMinValue())
+ return ConstantRange(getBitWidth(), /*isFullSet=*/true);
+ return ConstantRange(umax, APInt::getNullValue(getBitWidth()));
+}
+
+ConstantRange
ConstantRange::shl(const ConstantRange &Other) const {
if (isEmptySet() || Other.isEmptySet())
return ConstantRange(getBitWidth(), /*isFullSet=*/false);