1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

SCEV: Compress disposition pairs.

Composing DenseMaps and SmallVectors is still somewhat suboptimal,
but this at least halves the size of the vector elements. NFC.

llvm-svn: 228497
This commit is contained in:
Benjamin Kramer 2015-02-07 16:41:12 +00:00
parent 28fba477c6
commit c705a27ee2
2 changed files with 24 additions and 21 deletions

View File

@ -372,14 +372,17 @@ namespace llvm {
/// LoopDispositions - Memoized computeLoopDisposition results.
DenseMap<const SCEV *,
SmallVector<std::pair<const Loop *, LoopDisposition>, 2> > LoopDispositions;
SmallVector<PointerIntPair<const Loop *, 2, LoopDisposition>, 2>>
LoopDispositions;
/// computeLoopDisposition - Compute a LoopDisposition value.
LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L);
/// BlockDispositions - Memoized computeBlockDisposition results.
DenseMap<const SCEV *,
SmallVector<std::pair<const BasicBlock *, BlockDisposition>, 2> > BlockDispositions;
DenseMap<
const SCEV *,
SmallVector<PointerIntPair<const BasicBlock *, 2, BlockDisposition>, 2>>
BlockDispositions;
/// computeBlockDisposition - Compute a BlockDisposition value.
BlockDisposition computeBlockDisposition(const SCEV *S, const BasicBlock *BB);

View File

@ -8000,17 +8000,17 @@ void ScalarEvolution::print(raw_ostream &OS, const Module *) const {
ScalarEvolution::LoopDisposition
ScalarEvolution::getLoopDisposition(const SCEV *S, const Loop *L) {
SmallVector<std::pair<const Loop *, LoopDisposition>, 2> &Values = LoopDispositions[S];
for (unsigned u = 0; u < Values.size(); u++) {
if (Values[u].first == L)
return Values[u].second;
auto &Values = LoopDispositions[S];
for (auto &V : Values) {
if (V.getPointer() == L)
return V.getInt();
}
Values.push_back(std::make_pair(L, LoopVariant));
Values.emplace_back(L, LoopVariant);
LoopDisposition D = computeLoopDisposition(S, L);
SmallVector<std::pair<const Loop *, LoopDisposition>, 2> &Values2 = LoopDispositions[S];
for (unsigned u = Values2.size(); u > 0; u--) {
if (Values2[u - 1].first == L) {
Values2[u - 1].second = D;
auto &Values2 = LoopDispositions[S];
for (auto &V : make_range(Values2.rbegin(), Values2.rend())) {
if (V.getPointer() == L) {
V.setInt(D);
break;
}
}
@ -8106,17 +8106,17 @@ bool ScalarEvolution::hasComputableLoopEvolution(const SCEV *S, const Loop *L) {
ScalarEvolution::BlockDisposition
ScalarEvolution::getBlockDisposition(const SCEV *S, const BasicBlock *BB) {
SmallVector<std::pair<const BasicBlock *, BlockDisposition>, 2> &Values = BlockDispositions[S];
for (unsigned u = 0; u < Values.size(); u++) {
if (Values[u].first == BB)
return Values[u].second;
auto &Values = BlockDispositions[S];
for (auto &V : Values) {
if (V.getPointer() == BB)
return V.getInt();
}
Values.push_back(std::make_pair(BB, DoesNotDominateBlock));
Values.emplace_back(BB, DoesNotDominateBlock);
BlockDisposition D = computeBlockDisposition(S, BB);
SmallVector<std::pair<const BasicBlock *, BlockDisposition>, 2> &Values2 = BlockDispositions[S];
for (unsigned u = Values2.size(); u > 0; u--) {
if (Values2[u - 1].first == BB) {
Values2[u - 1].second = D;
auto &Values2 = BlockDispositions[S];
for (auto &V : make_range(Values2.rbegin(), Values2.rend())) {
if (V.getPointer() == BB) {
V.setInt(D);
break;
}
}