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>
43 if (
empty() || Ranges.back().getUpper().slt(NewRange.
getLower())) {
44 Ranges.push_back(NewRange);
50 if (NewRange.
getUpper().
slt(Ranges.front().getLower())) {
51 Ranges.insert(Ranges.begin(), NewRange);
57 return a.
getLower().slt(b.getLower());
59 if (LowerBound != Ranges.end() && LowerBound->contains(NewRange))
64 Ranges.erase(LowerBound, Ranges.end());
66 if (!Ranges.empty() && NewRange.
getLower().
sle(Ranges.back().getUpper())) {
67 APInt NewLower = Ranges.back().getLower();
72 Ranges.push_back(NewRange);
74 for (
auto Iter = ExistingTail.
begin(); Iter != ExistingTail.
end(); Iter++) {
75 if (Ranges.back().getUpper().slt(Iter->getLower())) {
76 Ranges.push_back(*Iter);
78 APInt NewLower = Ranges.back().getLower();
93 if (Ranges.back().getUpper().sle(SubRange.
getLower()))
95 if (SubRange.
getUpper().
sle(Ranges.front().getLower()))
99 auto AppendRangeIfNonEmpty = [&Result](
APInt Start,
APInt End) {
103 for (
auto &
Range : Ranges) {
110 Result.push_back(
Range);
154 "ConstantRangeList bitwidths don't agree!");
161 if (Ranges[i].getLower().slt(CRL.Ranges[j].getLower())) {
162 PreviousRange = Ranges[i++];
164 PreviousRange = CRL.Ranges[j++];
171 auto UnionAndUpdateRange = [&PreviousRange,
174 Result.Ranges.push_back(PreviousRange);
182 while (i <
size() || j < CRL.
size()) {
183 if (j == CRL.
size() ||
184 (i <
size() && Ranges[i].getLower().slt(CRL.Ranges[j].getLower()))) {
186 UnionAndUpdateRange(Ranges[i++]);
189 UnionAndUpdateRange(CRL.Ranges[j++]);
192 Result.Ranges.push_back(PreviousRange);
205 "ConstantRangeList bitwidths don't agree!");
209 while (i <
size() && j < CRL.
size()) {
210 auto &
Range = this->Ranges[i];
211 auto &OtherRange = CRL.Ranges[j];
241#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...