summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/ConstantRange.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2007-03-02 03:33:05 +0000
committerNick Lewycky <nicholas@mxc.ca>2007-03-02 03:33:05 +0000
commitcf87f9eef5e971eb4c932fc66ec5caaee3f2ee09 (patch)
tree921c9fc711cb0259423c8de905964fdb78f73f20 /llvm/lib/Support/ConstantRange.cpp
parent4bd8cda3f047d41b8ba98b4460bc2984c8aed660 (diff)
downloadbcm5719-llvm-cf87f9eef5e971eb4c932fc66ec5caaee3f2ee09.tar.gz
bcm5719-llvm-cf87f9eef5e971eb4c932fc66ec5caaee3f2ee09.zip
Implement unionWith.
llvm-svn: 34833
Diffstat (limited to 'llvm/lib/Support/ConstantRange.cpp')
-rw-r--r--llvm/lib/Support/ConstantRange.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp
index ce4a25325a4..410c351890c 100644
--- a/llvm/lib/Support/ConstantRange.cpp
+++ b/llvm/lib/Support/ConstantRange.cpp
@@ -194,9 +194,18 @@ ConstantRange ConstantRange::unionWith(const ConstantRange &CR) const {
assert(getBitWidth() == CR.getBitWidth() &&
"ConstantRange types don't agree!");
- assert(0 && "Range union not implemented yet!");
+ if ( isFullSet() || CR.isEmptySet()) return *this;
+ if (CR.isFullSet() || isEmptySet()) return CR;
- return *this;
+ APInt L = Lower, U = Upper;
+
+ if (!contains(CR.Lower))
+ L = APIntOps::umin(L, CR.Lower);
+
+ if (!contains(CR.Upper - 1))
+ U = APIntOps::umax(U, CR.Upper);
+
+ return ConstantRange(L, U);
}
/// zeroExtend - Return a new range in the specified integer type, which must
OpenPOWER on IntegriCloud