[llvm-commits] [cfe-commits] [PATCH][Review Request] EarlyCSE stack overflow - bugzilla 11794
Jakob Stoklund Olesen
stoklund at 2pi.dk
Thu Jan 19 15:41:42 PST 2012
On Jan 19, 2012, at 1:41 PM, Lenny Maiorani wrote:
> Before I blindly stated that I thought std::stack or std::deque would be better, I decided I would verify this.
Yay for SCIENCE!
> I wrote a small test of a few different implementation (std::list, std::stack, std::deque, std::vector, and std::deque using iterator-insert) attempting to perform the same operations as the necessary ones in EarlyCSE.cpp. It is distilled down to just the performance of the actual data structures under the assumed conditions. Attached (stack-test.cpp).
>
> As it turns out, the "best" implementation in terms of performance is std::deque using the "iterator-insert", by a wide margin. On my lowly laptop, after compiling the test with 'clang++ -O2', I get the following results:
> List: 92.473490 seconds
> Stack: 15.575143 seconds
> Deque: 9.129154 seconds
> Deque iter insert: 7.384741 seconds
> Vector: 13.387473 seconds
Thanks for taking the time to do this and actually posting numbers.
However, it looks like you overlooked the scoped hash tables instantiated at the top of EarlyCSE::processNode. They nest.
Also, since you are basically running a pre-order DFS traversal of the DomTree, I think you are pushing too many nodes onto your stack. You should be able to do something similar to what DepthFirstIterator.h is doing.
You may also want to take a look at MachineCSE.cpp which is basically the same thing, without recursion.
/jakob
More information about the llvm-commits
mailing list