Add an inverse() method to ConstantRange.

llvm-svn: 110504
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp
index fb04428..26a23ef 100644
--- a/llvm/lib/Support/ConstantRange.cpp
+++ b/llvm/lib/Support/ConstantRange.cpp
@@ -655,6 +655,17 @@
   return ConstantRange(min, max);
 }
 
+ConstantRange ConstantRange::inverse() const {
+  if (isFullSet()) {
+    return ConstantRange(APInt::getNullValue(Lower.getBitWidth()),
+      APInt::getNullValue(Lower.getBitWidth()));
+  } else if (isEmptySet()) {
+    return ConstantRange(APInt::getAllOnesValue(Lower.getBitWidth()),
+      APInt::getAllOnesValue(Lower.getBitWidth()));
+  }
+  return ConstantRange(Upper, Lower);
+}
+
 /// print - Print out the bounds to a stream...
 ///
 void ConstantRange::print(raw_ostream &OS) const {