[PATCH] D33088: [LiveVariables] Switch Kill/Defs sets to be `DenseSet`
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 20:20:42 PDT 2017
davide created this revision.
The testcase in https://bugs.llvm.org/show_bug.cgi?id=32984 went from 3 minutes to 10 minutes after a change that made the LoopUnroll pass more aggressive (increasing the threshold).
`-time-passes` reveals large part of the time is spent in `PHI Elimination` (in the backend).
My profiling shows all the time of PHI elimination goes to `llvm::LiveVariables::addNewBlock`. This is because we keep Defs/Kills registers in a SmallSet, and `lvm/ADT/SmallSet.h -> VIterator vfind(const T &V);` is `O(N)`.
Switching to a DenseSet reduces the time spent in the pass from 297 seconds to 97 seconds. Profiling still shows a lot of time is spent iterating the data structure, so I guess there's room for improvement.
I tried a `SparseBitVector` and it's slightly slower than the `DenseMap` solution. I wanted to try a `BitVector` but I'm not sure I have an upper bound on the number of elements.
https://reviews.llvm.org/D33088
Files:
lib/CodeGen/LiveVariables.cpp
Index: lib/CodeGen/LiveVariables.cpp
===================================================================
--- lib/CodeGen/LiveVariables.cpp
+++ lib/CodeGen/LiveVariables.cpp
@@ -767,7 +767,7 @@
MachineBasicBlock *SuccBB) {
const unsigned NumNew = BB->getNumber();
- SmallSet<unsigned, 16> Defs, Kills;
+ DenseSet<unsigned, 16> Defs, Kills;
MachineBasicBlock::iterator BBI = SuccBB->begin(), BBE = SuccBB->end();
for (; BBI != BBE && BBI->isPHI(); ++BBI) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33088.98576.patch
Type: text/x-patch
Size: 503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170511/d774a452/attachment.bin>
More information about the llvm-commits
mailing list