diff options
author | Manman Ren <manman.ren@gmail.com> | 2014-02-28 23:05:31 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2014-02-28 23:05:31 +0000 |
commit | 5de568068963748c789a42777f1e7f9fade7403b (patch) | |
tree | cf769e8cf85db73df7943eae92990fdabffd878f /lib/CodeGen/SpillPlacement.cpp | |
parent | c1d2eda56567d3e1d8e3b85f06a5c3bd068ae29d (diff) | |
download | llvm-5de568068963748c789a42777f1e7f9fade7403b.tar.gz llvm-5de568068963748c789a42777f1e7f9fade7403b.tar.bz2 llvm-5de568068963748c789a42777f1e7f9fade7403b.tar.xz |
SpillPlacement: fix a bug in iterate.
Inside iterate, we scan backwards then scan forwards in a loop. When iteration
is not zero, the last node was just updated so we can skip it. But when
iteration is zero, we can't skip the last node.
For the testing case, fixing this will save a spill and move register copies
from hot path to cold path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SpillPlacement.cpp')
-rw-r--r-- | lib/CodeGen/SpillPlacement.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/CodeGen/SpillPlacement.cpp b/lib/CodeGen/SpillPlacement.cpp index 02c2035f4f..fb5b927d49 100644 --- a/lib/CodeGen/SpillPlacement.cpp +++ b/lib/CodeGen/SpillPlacement.cpp @@ -323,10 +323,12 @@ void SpillPlacement::iterate() { // affect the entire network in a single iteration. That means very fast // convergence, usually in a single iteration. for (unsigned iteration = 0; iteration != 10; ++iteration) { - // Scan backwards, skipping the last node which was just updated. + // Scan backwards, skipping the last node when iteration is not zero. When + // iteration is not zero, the last node was just updated. bool Changed = false; for (SmallVectorImpl<unsigned>::const_reverse_iterator I = - llvm::next(Linked.rbegin()), E = Linked.rend(); I != E; ++I) { + iteration == 0 ? Linked.rbegin() : llvm::next(Linked.rbegin()), + E = Linked.rend(); I != E; ++I) { unsigned n = *I; if (nodes[n].update(nodes)) { Changed = true; |