diff options
| author | Vedant Kumar <vsk@apple.com> | 2018-11-19 19:54:27 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2018-11-19 19:54:27 +0000 |
| commit | 4de31bba51b884bdfc7eb688958d9dc517da8353 (patch) | |
| tree | 8bfd8a142284649e9502ed52fe786cd312fc5922 /llvm/lib/Transforms/InstCombine | |
| parent | 740122fb8cb6a38ad072d3da26f6641434f30761 (diff) | |
| download | bcm5719-llvm-4de31bba51b884bdfc7eb688958d9dc517da8353.tar.gz bcm5719-llvm-4de31bba51b884bdfc7eb688958d9dc517da8353.zip | |
[IR] Add hasNPredecessors, hasNPredecessorsOrMore to BasicBlock
Add methods to BasicBlock which make it easier to efficiently check
whether a block has N (or more) predecessors.
This can be more efficient than using pred_size(), which is a linear
time operation.
We might consider adding similar methods for successors. I haven't done
so in this patch because succ_size() is already O(1).
With this patch applied, I measured a 0.065% compile-time reduction in
user time for running `opt -O3` on the sqlite3 amalgamation (30 trials).
The change in mergeStoreIntoSuccessor alone saves 45 million linked list
iterations in a stage2 Release build of llc.
See llvm.org/PR39702 for a harder but more general way of achieving
similar results.
Differential Revision: https://reviews.llvm.org/D54686
llvm-svn: 347256
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 670168bf537..e2f54606f2d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -1526,7 +1526,7 @@ bool InstCombiner::mergeStoreIntoSuccessor(StoreInst &SI) { // Check if the successor block has exactly 2 incoming edges. BasicBlock *StoreBB = SI.getParent(); BasicBlock *DestBB = StoreBB->getTerminator()->getSuccessor(0); - if (pred_size(DestBB) != 2) + if (!DestBB->hasNPredecessors(2)) return false; // Capture the other block (the block that doesn't contain our store). |

