[llvm-commits] CVS: llvm/lib/Support/ConstantRange.cpp

Nick Lewycky nicholas at mxc.ca
Thu Mar 1 19:33:22 PST 2007



Changes in directory llvm/lib/Support:

ConstantRange.cpp updated: 1.39 -> 1.40
---
Log message:

Implement unionWith.


---
Diffs of the changes:  (+11 -2)

 ConstantRange.cpp |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)


Index: llvm/lib/Support/ConstantRange.cpp
diff -u llvm/lib/Support/ConstantRange.cpp:1.39 llvm/lib/Support/ConstantRange.cpp:1.40
--- llvm/lib/Support/ConstantRange.cpp:1.39	Thu Mar  1 01:54:15 2007
+++ llvm/lib/Support/ConstantRange.cpp	Thu Mar  1 21:33:05 2007
@@ -194,9 +194,18 @@
   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






More information about the llvm-commits mailing list