#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
+#include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
// than RHS, respectively. A three-way result allows recursive comparisons to be
// more efficient.
static int CompareSCEVComplexity(
- SmallSet<std::pair<const SCEV *, const SCEV *>, 8> &EqCacheSCEV,
+ EquivalenceClasses<const SCEV *> &EqCacheSCEV,
const LoopInfo *const LI, const SCEV *LHS, const SCEV *RHS,
DominatorTree &DT, unsigned Depth = 0) {
// Fast-path: SCEVs are uniqued so we can do a quick equality check.
if (LType != RType)
return (int)LType - (int)RType;
- if (Depth > MaxSCEVCompareDepth || EqCacheSCEV.count({LHS, RHS}))
+ if (Depth > MaxSCEVCompareDepth || EqCacheSCEV.isEquivalent(LHS, RHS))
return 0;
// Aside from the getSCEVType() ordering, the particular ordering
// isn't very important except that it's beneficial to be consistent,
int X = CompareValueComplexity(EqCache, LI, LU->getValue(), RU->getValue(),
Depth + 1);
if (X == 0)
- EqCacheSCEV.insert({LHS, RHS});
+ EqCacheSCEV.unionSets(LHS, RHS);
return X;
}
if (X != 0)
return X;
}
- EqCacheSCEV.insert({LHS, RHS});
+ EqCacheSCEV.unionSets(LHS, RHS);
return 0;
}
if (X != 0)
return X;
}
- EqCacheSCEV.insert({LHS, RHS});
+ EqCacheSCEV.unionSets(LHS, RHS);
return 0;
}
X = CompareSCEVComplexity(EqCacheSCEV, LI, LC->getRHS(), RC->getRHS(), DT,
Depth + 1);
if (X == 0)
- EqCacheSCEV.insert({LHS, RHS});
+ EqCacheSCEV.unionSets(LHS, RHS);
return X;
}
int X = CompareSCEVComplexity(EqCacheSCEV, LI, LC->getOperand(),
RC->getOperand(), DT, Depth + 1);
if (X == 0)
- EqCacheSCEV.insert({LHS, RHS});
+ EqCacheSCEV.unionSets(LHS, RHS);
return X;
}
LoopInfo *LI, DominatorTree &DT) {
if (Ops.size() < 2) return; // Noop
- SmallSet<std::pair<const SCEV *, const SCEV *>, 8> EqCache;
+ EquivalenceClasses<const SCEV *> EqCache;
if (Ops.size() == 2) {
// This is the common case, which also happens to be trivially simple.
// Special case it.