Index: lib/Analysis/ScalarEvolution.cpp =================================================================== --- lib/Analysis/ScalarEvolution.cpp +++ lib/Analysis/ScalarEvolution.cpp @@ -549,10 +549,10 @@ /// Since we do not continue running this routine on expression trees once we /// have seen unequal values, there is no need to track them in the cache. static int -CompareValueComplexity(SmallSet, 8> &EqCache, +CompareValueComplexity(DisjointSetUnion &EqCache, const LoopInfo *const LI, Value *LV, Value *RV, unsigned Depth) { - if (Depth > MaxValueCompareDepth || EqCache.count({LV, RV})) + if (Depth > MaxValueCompareDepth || EqCache.isInSameSet(LV, RV)) return 0; // Order pointer values after integer values. This helps SCEVExpander form @@ -619,7 +619,7 @@ } } - EqCache.insert({LV, RV}); + EqCache.mergeSetsOf(LV, RV); return 0; } @@ -649,7 +649,7 @@ const SCEVUnknown *LU = cast(LHS); const SCEVUnknown *RU = cast(RHS); - SmallSet, 8> EqCache; + DisjointSetUnion EqCache; int X = CompareValueComplexity(EqCache, LI, LU->getValue(), RU->getValue(), Depth + 1); if (X == 0)