mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-13 14:46:15 +00:00
SLPVectorizer: Instead of just performing CSE on dead blocks ignore them completely.
Turns out that there is a very cheap way of testing whether a block is dead, just look it up in the DomTree. We have to do this anyways so just ignore unreachable blocks before sorting by domination. This restores a proper ordering for std::stable_sort when dead code is present. Covered by existing tests & buildbots running in STL debug mode (MSVC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f5e04c38cd
commit
4db3f41012
@ -1812,11 +1812,19 @@ void BoUpSLP::optimizeGatherSequence() {
|
|||||||
Insert->moveBefore(PreHeader->getTerminator());
|
Insert->moveBefore(PreHeader->getTerminator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make a list of all reachable blocks in our CSE queue.
|
||||||
|
SmallVector<const DomTreeNode *, 8> CSEWorkList;
|
||||||
|
CSEWorkList.reserve(CSEBlocks.size());
|
||||||
|
for (BasicBlock *BB : CSEBlocks)
|
||||||
|
if (DomTreeNode *N = DT->getNode(BB)) {
|
||||||
|
assert(DT->isReachableFromEntry(N));
|
||||||
|
CSEWorkList.push_back(N);
|
||||||
|
}
|
||||||
|
|
||||||
// Sort blocks by domination. This ensures we visit a block after all blocks
|
// Sort blocks by domination. This ensures we visit a block after all blocks
|
||||||
// dominating it are visited.
|
// dominating it are visited.
|
||||||
SmallVector<BasicBlock *, 8> CSEWorkList(CSEBlocks.begin(), CSEBlocks.end());
|
|
||||||
std::stable_sort(CSEWorkList.begin(), CSEWorkList.end(),
|
std::stable_sort(CSEWorkList.begin(), CSEWorkList.end(),
|
||||||
[this](const BasicBlock *A, const BasicBlock *B) {
|
[this](const DomTreeNode *A, const DomTreeNode *B) {
|
||||||
return DT->properlyDominates(A, B);
|
return DT->properlyDominates(A, B);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1824,13 +1832,10 @@ void BoUpSLP::optimizeGatherSequence() {
|
|||||||
// instructions. TODO: We can further optimize this scan if we split the
|
// instructions. TODO: We can further optimize this scan if we split the
|
||||||
// instructions into different buckets based on the insert lane.
|
// instructions into different buckets based on the insert lane.
|
||||||
SmallVector<Instruction *, 16> Visited;
|
SmallVector<Instruction *, 16> Visited;
|
||||||
for (SmallVectorImpl<BasicBlock *>::iterator I = CSEWorkList.begin(),
|
for (auto I = CSEWorkList.begin(), E = CSEWorkList.end(); I != E; ++I) {
|
||||||
E = CSEWorkList.end();
|
assert((I == CSEWorkList.begin() || !DT->dominates(*I, *std::prev(I))) &&
|
||||||
I != E; ++I) {
|
|
||||||
assert((I == CSEWorkList.begin() || !DT->isReachableFromEntry(*I) ||
|
|
||||||
!DT->dominates(*I, *std::prev(I))) &&
|
|
||||||
"Worklist not sorted properly!");
|
"Worklist not sorted properly!");
|
||||||
BasicBlock *BB = *I;
|
BasicBlock *BB = (*I)->getBlock();
|
||||||
// For all instructions in blocks containing gather sequences:
|
// For all instructions in blocks containing gather sequences:
|
||||||
for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e;) {
|
for (BasicBlock::iterator it = BB->begin(), e = BB->end(); it != e;) {
|
||||||
Instruction *In = it++;
|
Instruction *In = it++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user