large slowdown in DAGCombiner::MergeConsecutiveStores

Hello all,

We are seeing a large compiler performance regression in moving from LLVM 6.0.1 to 8.0.1. We have a long function (~50000 instructions) that used to compile in about a minute but now takes at least an hour. All the time is in MergeConsecutiveStores, I believe due to super-linear behavior in analyzing very long chains of stores. For example, this change makes the problem go away:

--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -16011,6 +16011,9 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) {
StoreNodes.begin() + NumConsecutiveStores);
continue;
}
+ else if (NumConsecutiveStores > 128) {
+ return RV;
+ }

Does anybody have any advice on what a good way to fix this would be? Does it make sense to have some kind of limit on how many stores we try to merge? (Even if so, I don’t know whether the above is the right way to implement such a limit.)

Thanks in advance for any suggestions.

-Jeff

Hi,

Thanks for those references. I tried this with a ~1 week old master and indeed the situation is much better. It’s now about 2x slower than 6.0.1. The extra time is still in MergeConsecutiveStores. Do you think there’s any scope for further limiting the work done there? The performance is now at least tolerable though.

Many thanks to everyone who has looked into these issues; this makes a big difference for some interesting Julia use cases.

-Jeff

Hi,