@@ -83,6 +83,13 @@ int FunctionComparator::cmpAPInts(const APInt &L, const APInt &R) const {
8383 return 0 ;
8484}
8585
86+ int FunctionComparator::cmpConstantRanges (const ConstantRange &L,
87+ const ConstantRange &R) const {
88+ if (int Res = cmpAPInts (L.getLower (), R.getLower ()))
89+ return Res;
90+ return cmpAPInts (L.getUpper (), R.getUpper ());
91+ }
92+
8693int FunctionComparator::cmpAPFloats (const APFloat &L, const APFloat &R) const {
8794 // Floats are ordered first by semantics (i.e. float, double, half, etc.),
8895 // then by value interpreted as a bitstring (aka APInt).
@@ -147,12 +154,22 @@ int FunctionComparator::cmpAttrs(const AttributeList L,
147154 if (LA.getKindAsEnum () != RA.getKindAsEnum ())
148155 return cmpNumbers (LA.getKindAsEnum (), RA.getKindAsEnum ());
149156
150- const ConstantRange &LCR = LA.getRange ();
151- const ConstantRange &RCR = RA.getRange ();
152- if (int Res = cmpAPInts (LCR.getLower (), RCR.getLower ()))
157+ if (int Res = cmpConstantRanges (LA.getRange (), RA.getRange ()))
153158 return Res;
154- if (int Res = cmpAPInts (LCR.getUpper (), RCR.getUpper ()))
159+ continue ;
160+ } else if (LA.isConstantRangeListAttribute () &&
161+ RA.isConstantRangeListAttribute ()) {
162+ if (LA.getKindAsEnum () != RA.getKindAsEnum ())
163+ return cmpNumbers (LA.getKindAsEnum (), RA.getKindAsEnum ());
164+
165+ ArrayRef<ConstantRange> CRL = LA.getValueAsConstantRangeList ();
166+ ArrayRef<ConstantRange> CRR = RA.getValueAsConstantRangeList ();
167+ if (int Res = cmpNumbers (CRL.size (), CRR.size ()))
155168 return Res;
169+
170+ for (const auto &[L, R] : zip (CRL, CRR))
171+ if (int Res = cmpConstantRanges (L, R))
172+ return Res;
156173 continue ;
157174 }
158175 if (LA < RA)
@@ -441,9 +458,7 @@ int FunctionComparator::cmpConstants(const Constant *L,
441458 if (InRangeL) {
442459 if (!InRangeR)
443460 return 1 ;
444- if (int Res = cmpAPInts (InRangeL->getLower (), InRangeR->getLower ()))
445- return Res;
446- if (int Res = cmpAPInts (InRangeL->getUpper (), InRangeR->getUpper ()))
461+ if (int Res = cmpConstantRanges (*InRangeL, *InRangeR))
447462 return Res;
448463 } else if (InRangeR) {
449464 return -1 ;
0 commit comments