15 if (RangesRef.
empty())
17 auto Range = RangesRef[0];
20 for (
unsigned i = 1; i < RangesRef.
size(); i++) {
21 auto CurRange = RangesRef[i];
22 auto PreRange = RangesRef[i - 1];
23 if (CurRange.getLower().sge(CurRange.getUpper()) ||
24 CurRange.getLower().sle(PreRange.getUpper()))
30std::optional<ConstantRangeList>
44 if (
empty() || Ranges.back().getUpper().slt(NewRange.
getLower())) {
45 Ranges.push_back(NewRange);
48 if (NewRange.
getUpper().
slt(Ranges.front().getLower())) {
49 Ranges.insert(Ranges.begin(), NewRange);
55 return a.
getLower().slt(b.getLower());
57 if (LowerBound != Ranges.end() && LowerBound->contains(NewRange))
62 Ranges.erase(LowerBound, Ranges.end());
64 if (!Ranges.empty() && NewRange.
getLower().
sle(Ranges.back().getUpper())) {
65 APInt NewLower = Ranges.back().getLower();
70 Ranges.push_back(NewRange);
72 for (
auto Iter = ExistingTail.
begin(); Iter != ExistingTail.
end(); Iter++) {
73 if (Ranges.back().getUpper().slt(Iter->getLower())) {
74 Ranges.push_back(*Iter);
76 APInt NewLower = Ranges.back().getLower();
91 if (Ranges.back().getUpper().sle(SubRange.
getLower()))
93 if (SubRange.
getUpper().
sle(Ranges.front().getLower()))
97 auto AppendRangeIfNonEmpty = [&Result](
APInt Start,
APInt End) {
101 for (
auto &
Range : Ranges) {
108 Result.push_back(
Range);
146 "ConstantRangeList bitwidths don't agree!");
158 if (Ranges[i].getLower().slt(CRL.Ranges[j].getLower())) {
159 PreviousRange = Ranges[i++];
161 PreviousRange = CRL.Ranges[j++];
168 auto UnionAndUpdateRange = [&PreviousRange,
171 Result.Ranges.push_back(PreviousRange);
179 while (i <
size() || j < CRL.
size()) {
180 if (j == CRL.
size() ||
181 (i <
size() && Ranges[i].getLower().slt(CRL.Ranges[j].getLower()))) {
183 UnionAndUpdateRange(Ranges[i++]);
186 UnionAndUpdateRange(CRL.Ranges[j++]);
189 Result.Ranges.push_back(PreviousRange);
196 "ConstantRangeList bitwidths don't agree!");
206 while (i <
size() && j < CRL.
size()) {
207 auto &
Range = this->Ranges[i];
208 auto &OtherRange = CRL.Ranges[j];
238#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
bool slt(const APInt &RHS) const
Signed less than comparison.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
This class represents a list of constant ranges.
void subtract(const ConstantRange &SubRange)
uint32_t getBitWidth() const
Get the bit width of this ConstantRangeList.
void insert(const ConstantRange &NewRange)
Insert a new range to Ranges and keep the list ordered.
bool empty() const
Return true if this list contains no members.
void print(raw_ostream &OS) const
Print out the ranges to a stream.
static std::optional< ConstantRangeList > getConstantRangeList(ArrayRef< ConstantRange > RangesRef)
ConstantRangeList()=default
size_t size() const
Return the number of ranges in this ConstantRangeList.
ConstantRangeList intersectWith(const ConstantRangeList &CRL) const
Return the range list that results from the intersection of this ConstantRangeList with another Const...
ConstantRangeList unionWith(const ConstantRangeList &CRL) const
Return the range list that results from the union of this ConstantRangeList with another ConstantRang...
static bool isOrderedRanges(ArrayRef< ConstantRange > RangesRef)
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
bool isEmptySet() const
Return true if this set contains no members.
const APInt & getUpper() const
Return the upper value for this range.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class implements an extremely fast bulk output stream that can only output to a stream.
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
This is an optimization pass for GlobalISel generic memory operations.
void interleaveComma(const Container &c, StreamT &os, UnaryFunctor each_fn)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...