[llvm] Add ConstantRangeList::subtract(ConstantRange) (PR #97093)
    Haopeng Liu via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Jun 28 13:03:01 PDT 2024
    
    
  
================
@@ -81,6 +81,65 @@ void ConstantRangeList::insert(const ConstantRange &NewRange) {
   }
 }
 
+void ConstantRangeList::subtract(const ConstantRange &SubRange) {
+  if (SubRange.isEmptySet())
+    return;
+  assert(!SubRange.isFullSet() && "Do not support full set");
+  assert(SubRange.getLower().slt(SubRange.getUpper()));
+  assert(getBitWidth() == SubRange.getBitWidth());
+  // Handle common cases.
+  if (empty() || Ranges.back().getUpper().sle(SubRange.getLower())) {
+    return;
+  }
+  if (SubRange.getUpper().sle(Ranges.front().getLower())) {
----------------
haopliu wrote:
Ah, nice catch. Combined the CRL empty check and the "SubRange" empty check together.
https://github.com/llvm/llvm-project/pull/97093
    
    
More information about the llvm-commits
mailing list