@@ -597,11 +597,9 @@ void SCEVUnknown::allUsesReplacedWith(Value *New) {
597
597
///
598
598
/// Since we do not continue running this routine on expression trees once we
599
599
/// have seen unequal values, there is no need to track them in the cache.
600
- static int
601
- CompareValueComplexity(EquivalenceClasses<const Value *> &EqCacheValue,
602
- const LoopInfo *const LI, Value *LV, Value *RV,
603
- unsigned Depth) {
604
- if (Depth > MaxValueCompareDepth || EqCacheValue.isEquivalent(LV, RV))
600
+ static int CompareValueComplexity(const LoopInfo *const LI, Value *LV,
601
+ Value *RV, unsigned Depth) {
602
+ if (Depth > MaxValueCompareDepth)
605
603
return 0;
606
604
607
605
// Order pointer values after integer values. This helps SCEVExpander form
@@ -660,15 +658,13 @@ CompareValueComplexity(EquivalenceClasses<const Value *> &EqCacheValue,
660
658
return (int)LNumOps - (int)RNumOps;
661
659
662
660
for (unsigned Idx : seq(LNumOps)) {
663
- int Result =
664
- CompareValueComplexity(EqCacheValue, LI, LInst->getOperand(Idx),
665
- RInst->getOperand(Idx), Depth + 1);
661
+ int Result = CompareValueComplexity(LI, LInst->getOperand(Idx),
662
+ RInst->getOperand(Idx), Depth + 1);
666
663
if (Result != 0)
667
664
return Result;
668
665
}
669
666
}
670
667
671
- EqCacheValue.unionSets(LV, RV);
672
668
return 0;
673
669
}
674
670
@@ -679,7 +675,6 @@ CompareValueComplexity(EquivalenceClasses<const Value *> &EqCacheValue,
679
675
// not know if they are equivalent for sure.
680
676
static std::optional<int>
681
677
CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
682
- EquivalenceClasses<const Value *> &EqCacheValue,
683
678
const LoopInfo *const LI, const SCEV *LHS,
684
679
const SCEV *RHS, DominatorTree &DT, unsigned Depth = 0) {
685
680
// Fast-path: SCEVs are uniqued so we can do a quick equality check.
@@ -705,8 +700,8 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
705
700
const SCEVUnknown *LU = cast<SCEVUnknown>(LHS);
706
701
const SCEVUnknown *RU = cast<SCEVUnknown>(RHS);
707
702
708
- int X = CompareValueComplexity(EqCacheValue, LI, LU->getValue(),
709
- RU->getValue(), Depth + 1);
703
+ int X =
704
+ CompareValueComplexity(LI, LU->getValue(), RU->getValue(), Depth + 1);
710
705
if (X == 0)
711
706
EqCacheSCEV.unionSets(LHS, RHS);
712
707
return X;
@@ -773,8 +768,8 @@ CompareSCEVComplexity(EquivalenceClasses<const SCEV *> &EqCacheSCEV,
773
768
return (int)LNumOps - (int)RNumOps;
774
769
775
770
for (unsigned i = 0; i != LNumOps; ++i) {
776
- auto X = CompareSCEVComplexity(EqCacheSCEV, EqCacheValue, LI, LOps[i],
777
- ROps[i], DT, Depth + 1);
771
+ auto X = CompareSCEVComplexity(EqCacheSCEV, LI, LOps[i], ROps[i], DT ,
772
+ Depth + 1);
778
773
if (X != 0)
779
774
return X;
780
775
}
@@ -802,12 +797,10 @@ static void GroupByComplexity(SmallVectorImpl<const SCEV *> &Ops,
802
797
if (Ops.size() < 2) return; // Noop
803
798
804
799
EquivalenceClasses<const SCEV *> EqCacheSCEV;
805
- EquivalenceClasses<const Value *> EqCacheValue;
806
800
807
801
// Whether LHS has provably less complexity than RHS.
808
802
auto IsLessComplex = [&](const SCEV *LHS, const SCEV *RHS) {
809
- auto Complexity =
810
- CompareSCEVComplexity(EqCacheSCEV, EqCacheValue, LI, LHS, RHS, DT);
803
+ auto Complexity = CompareSCEVComplexity(EqCacheSCEV, LI, LHS, RHS, DT);
811
804
return Complexity && *Complexity < 0;
812
805
};
813
806
if (Ops.size() == 2) {
0 commit comments