@@ -653,8 +653,7 @@ static int CompareValueComplexity(const LoopInfo *const LI, Value *LV,
653
653
// If the max analysis depth was reached, return std::nullopt, assuming we do
654
654
// not know if they are equivalent for sure.
655
655
static 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,
658
657
const SCEV *RHS, DominatorTree &DT, unsigned Depth = 0) {
659
658
// Fast-path: SCEVs are uniqued so we can do a quick equality check.
660
659
if (LHS == RHS)
@@ -665,9 +664,6 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
665
664
if (LType != RType)
666
665
return (int)LType - (int)RType;
667
666
668
- if (EqCacheSCEV.isEquivalent(LHS, RHS))
669
- return 0;
670
-
671
667
if (Depth > MaxSCEVCompareDepth)
672
668
return std::nullopt;
673
669
@@ -681,8 +677,6 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
681
677
682
678
int X =
683
679
CompareValueComplexity(LI, LU->getValue(), RU->getValue(), Depth + 1);
684
- if (X == 0)
685
- EqCacheSCEV.unionSets(LHS, RHS);
686
680
return X;
687
681
}
688
682
@@ -747,12 +741,10 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
747
741
return (int)LNumOps - (int)RNumOps;
748
742
749
743
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);
752
745
if (X != 0)
753
746
return X;
754
747
}
755
- EqCacheSCEV.unionSets(LHS, RHS);
756
748
return 0;
757
749
}
758
750
@@ -775,11 +767,9 @@ static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops,
775
767
LoopInfo *LI, DominatorTree &DT) {
776
768
if (Ops.size() < 2) return; // Noop
777
769
778
- EquivalenceClasses<const SCEV *> EqCacheSCEV;
779
-
780
770
// Whether LHS has provably less complexity than RHS.
781
771
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);
783
773
return Complexity && *Complexity < 0;
784
774
};
785
775
if (Ops.size() == 2) {
0 commit comments