@@ -653,8 +653,7 @@ static int CompareValueComplexity(const LoopInfo *const LI, Value *LV,
653653// If the max analysis depth was reached, return std::nullopt, assuming we do
654654// not know if they are equivalent for sure.
655655static std::optional<int>
656- CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
657- const LoopInfo *const LI, const SCEV *LHS,
656+ CompareSCEVComplexity(const LoopInfo *const LI, const SCEV *LHS,
658657 const SCEV *RHS, DominatorTree &DT, unsigned Depth = 0) {
659658 // Fast-path: SCEVs are uniqued so we can do a quick equality check.
660659 if (LHS == RHS)
@@ -665,9 +664,6 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
665664 if (LType != RType)
666665 return (int)LType - (int)RType;
667666
668- if (EqCacheSCEV.isEquivalent(LHS, RHS))
669- return 0;
670-
671667 if (Depth > MaxSCEVCompareDepth)
672668 return std::nullopt;
673669
@@ -681,8 +677,6 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
681677
682678 int X =
683679 CompareValueComplexity(LI, LU->getValue(), RU->getValue(), Depth + 1);
684- if (X == 0)
685- EqCacheSCEV.unionSets(LHS, RHS);
686680 return X;
687681 }
688682
@@ -747,12 +741,10 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
747741 return (int)LNumOps - (int)RNumOps;
748742
749743 for (unsigned i = 0; i != LNumOps; ++i) {
750- auto X = CompareSCEVComplexity(EqCacheSCEV, LI, LOps[i], ROps[i], DT,
751- Depth + 1);
744+ auto X = CompareSCEVComplexity(LI, LOps[i], ROps[i], DT, Depth + 1);
752745 if (X != 0)
753746 return X;
754747 }
755- EqCacheSCEV.unionSets(LHS, RHS);
756748 return 0;
757749 }
758750
@@ -775,11 +767,9 @@ static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops,
775767 LoopInfo *LI, DominatorTree &DT) {
776768 if (Ops.size() < 2) return; // Noop
777769
778- EquivalenceClasses<const SCEV *> EqCacheSCEV;
779-
780770 // Whether LHS has provably less complexity than RHS.
781771 auto IsLessComplex = [&](const SCEV *LHS, const SCEV *RHS) {
782- auto Complexity = CompareSCEVComplexity(EqCacheSCEV, LI, LHS, RHS, DT);
772+ auto Complexity = CompareSCEVComplexity(LI, LHS, RHS, DT);
783773 return Complexity && *Complexity < 0;
784774 };
785775 if (Ops.size() == 2) {
0 commit comments