aboutsummaryrefslogtreecommitdiffstats
path: root/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
commitc6a28fcf5db2b6e81607e45cd5210e3e07834eed (patch)
tree22587c26b25698307a5b48ab3de07224b75f853a /lib/Support/ConstantRange.cpp
parent67ef241f45331d1df572ab95f5f19475d8e48a9e (diff)
downloadexternal_llvm-c6a28fcf5db2b6e81607e45cd5210e3e07834eed.zip
external_llvm-c6a28fcf5db2b6e81607e45cd5210e3e07834eed.tar.gz
external_llvm-c6a28fcf5db2b6e81607e45cd5210e3e07834eed.tar.bz2
Implement unionWith.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/ConstantRange.cpp')
-rw-r--r--lib/Support/ConstantRange.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp
index ce4a253..410c351 100644
--- a/lib/Support/ConstantRange.cpp
+++ b/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