mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-26 05:00:26 +00:00
BBVectorize: Remove the linear searches from pair connection searching
This removes the last of the linear searches over ranges of std::multimap iterators, giving a 7% speedup on the doduc.bc input from PR15222. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174859 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2f0e63cc16
commit
00f63b1b84
@ -281,6 +281,7 @@ namespace {
|
|||||||
|
|
||||||
void computePairsConnectedTo(
|
void computePairsConnectedTo(
|
||||||
std::multimap<Value *, Value *> &CandidatePairs,
|
std::multimap<Value *, Value *> &CandidatePairs,
|
||||||
|
DenseSet<ValuePair> &CandidatePairsSet,
|
||||||
std::vector<Value *> &PairableInsts,
|
std::vector<Value *> &PairableInsts,
|
||||||
std::multimap<ValuePair, ValuePair> &ConnectedPairs,
|
std::multimap<ValuePair, ValuePair> &ConnectedPairs,
|
||||||
DenseMap<VPPair, unsigned> &PairConnectionTypes,
|
DenseMap<VPPair, unsigned> &PairConnectionTypes,
|
||||||
@ -666,19 +667,6 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if J is the second element in some pair referenced by
|
|
||||||
// some multimap pair iterator pair.
|
|
||||||
template <typename V>
|
|
||||||
bool isSecondInIteratorPair(V J, std::pair<
|
|
||||||
typename std::multimap<V, V>::iterator,
|
|
||||||
typename std::multimap<V, V>::iterator> PairRange) {
|
|
||||||
for (typename std::multimap<V, V>::iterator K = PairRange.first;
|
|
||||||
K != PairRange.second; ++K)
|
|
||||||
if (K->second == J) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isPureIEChain(InsertElementInst *IE) {
|
bool isPureIEChain(InsertElementInst *IE) {
|
||||||
InsertElementInst *IENext = IE;
|
InsertElementInst *IENext = IE;
|
||||||
do {
|
do {
|
||||||
@ -1253,6 +1241,7 @@ namespace {
|
|||||||
// output of PI or PJ.
|
// output of PI or PJ.
|
||||||
void BBVectorize::computePairsConnectedTo(
|
void BBVectorize::computePairsConnectedTo(
|
||||||
std::multimap<Value *, Value *> &CandidatePairs,
|
std::multimap<Value *, Value *> &CandidatePairs,
|
||||||
|
DenseSet<ValuePair> &CandidatePairsSet,
|
||||||
std::vector<Value *> &PairableInsts,
|
std::vector<Value *> &PairableInsts,
|
||||||
std::multimap<ValuePair, ValuePair> &ConnectedPairs,
|
std::multimap<ValuePair, ValuePair> &ConnectedPairs,
|
||||||
DenseMap<VPPair, unsigned> &PairConnectionTypes,
|
DenseMap<VPPair, unsigned> &PairConnectionTypes,
|
||||||
@ -1274,8 +1263,6 @@ namespace {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
VPIteratorPair IPairRange = CandidatePairs.equal_range(*I);
|
|
||||||
|
|
||||||
// For each use of the first variable, look for uses of the second
|
// For each use of the first variable, look for uses of the second
|
||||||
// variable...
|
// variable...
|
||||||
for (Value::use_iterator J = P.second->use_begin(),
|
for (Value::use_iterator J = P.second->use_begin(),
|
||||||
@ -1284,17 +1271,15 @@ namespace {
|
|||||||
P.second == SJ->getPointerOperand())
|
P.second == SJ->getPointerOperand())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VPIteratorPair JPairRange = CandidatePairs.equal_range(*J);
|
|
||||||
|
|
||||||
// Look for <I, J>:
|
// Look for <I, J>:
|
||||||
if (isSecondInIteratorPair<Value*>(*J, IPairRange)) {
|
if (CandidatePairsSet.count(ValuePair(*I, *J))) {
|
||||||
VPPair VP(P, ValuePair(*I, *J));
|
VPPair VP(P, ValuePair(*I, *J));
|
||||||
ConnectedPairs.insert(VP);
|
ConnectedPairs.insert(VP);
|
||||||
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionDirect));
|
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionDirect));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for <J, I>:
|
// Look for <J, I>:
|
||||||
if (isSecondInIteratorPair<Value*>(*I, JPairRange)) {
|
if (CandidatePairsSet.count(ValuePair(*J, *I))) {
|
||||||
VPPair VP(P, ValuePair(*J, *I));
|
VPPair VP(P, ValuePair(*J, *I));
|
||||||
ConnectedPairs.insert(VP);
|
ConnectedPairs.insert(VP);
|
||||||
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionSwap));
|
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionSwap));
|
||||||
@ -1309,7 +1294,7 @@ namespace {
|
|||||||
P.first == SJ->getPointerOperand())
|
P.first == SJ->getPointerOperand())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isSecondInIteratorPair<Value*>(*J, IPairRange)) {
|
if (CandidatePairsSet.count(ValuePair(*I, *J))) {
|
||||||
VPPair VP(P, ValuePair(*I, *J));
|
VPPair VP(P, ValuePair(*I, *J));
|
||||||
ConnectedPairs.insert(VP);
|
ConnectedPairs.insert(VP);
|
||||||
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionSplat));
|
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionSplat));
|
||||||
@ -1328,14 +1313,12 @@ namespace {
|
|||||||
P.second == SI->getPointerOperand())
|
P.second == SI->getPointerOperand())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
VPIteratorPair IPairRange = CandidatePairs.equal_range(*I);
|
|
||||||
|
|
||||||
for (Value::use_iterator J = P.second->use_begin(); J != E; ++J) {
|
for (Value::use_iterator J = P.second->use_begin(); J != E; ++J) {
|
||||||
if ((SJ = dyn_cast<StoreInst>(*J)) &&
|
if ((SJ = dyn_cast<StoreInst>(*J)) &&
|
||||||
P.second == SJ->getPointerOperand())
|
P.second == SJ->getPointerOperand())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (isSecondInIteratorPair<Value*>(*J, IPairRange)) {
|
if (CandidatePairsSet.count(ValuePair(*I, *J))) {
|
||||||
VPPair VP(P, ValuePair(*I, *J));
|
VPPair VP(P, ValuePair(*I, *J));
|
||||||
ConnectedPairs.insert(VP);
|
ConnectedPairs.insert(VP);
|
||||||
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionSplat));
|
PairConnectionTypes.insert(VPPairWithType(VP, PairConnectionSplat));
|
||||||
@ -1352,6 +1335,10 @@ namespace {
|
|||||||
std::vector<Value *> &PairableInsts,
|
std::vector<Value *> &PairableInsts,
|
||||||
std::multimap<ValuePair, ValuePair> &ConnectedPairs,
|
std::multimap<ValuePair, ValuePair> &ConnectedPairs,
|
||||||
DenseMap<VPPair, unsigned> &PairConnectionTypes) {
|
DenseMap<VPPair, unsigned> &PairConnectionTypes) {
|
||||||
|
DenseSet<ValuePair> CandidatePairsSet;
|
||||||
|
for (std::multimap<Value *, Value *>::iterator I = CandidatePairs.begin(),
|
||||||
|
E = CandidatePairs.end(); I != E; ++I)
|
||||||
|
CandidatePairsSet.insert(*I);
|
||||||
|
|
||||||
for (std::vector<Value *>::iterator PI = PairableInsts.begin(),
|
for (std::vector<Value *>::iterator PI = PairableInsts.begin(),
|
||||||
PE = PairableInsts.end(); PI != PE; ++PI) {
|
PE = PairableInsts.end(); PI != PE; ++PI) {
|
||||||
@ -1359,7 +1346,7 @@ namespace {
|
|||||||
|
|
||||||
for (std::multimap<Value *, Value *>::iterator P = choiceRange.first;
|
for (std::multimap<Value *, Value *>::iterator P = choiceRange.first;
|
||||||
P != choiceRange.second; ++P)
|
P != choiceRange.second; ++P)
|
||||||
computePairsConnectedTo(CandidatePairs, PairableInsts,
|
computePairsConnectedTo(CandidatePairs, CandidatePairsSet, PairableInsts,
|
||||||
ConnectedPairs, PairConnectionTypes, *P);
|
ConnectedPairs, PairConnectionTypes, *P);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user