[DAGCombine] Disable finding better chains for stores at O0
authorSimon Dardis <simon.dardis@mips.com>
Tue, 28 Nov 2017 04:07:59 +0000 (04:07 +0000)
committerSimon Dardis <simon.dardis@mips.com>
Tue, 28 Nov 2017 04:07:59 +0000 (04:07 +0000)
commit3aeb1a54045db3aa878d9d71bab212f668f0e1d5
tree30958396f66f8689bdf69c22cbd51f224fc80b39
parenteca985847ce948180e28e0d407d00e7b6ac35eaa
[DAGCombine] Disable finding better chains for stores at O0

Unoptimized IR can have linear sequences of stores to an array, where the
initial GEP for the first store is formed from the pointer to the array, and the
GEP for each store after the first is formed from the previous GEP with some
offset in an inductive fashion.

The (large) resulting DAG when analyzed by DAGCombine undergoes an excessive
number of combines as each store node is examined every time its' offset node
is combined with any child of the offset. One of the transformations is
findBetterNeighborChains which assists MergeConsecutiveStores. The former
relies on repeated chain walking to do its' work, however MergeConsecutiveStores
is disabled at O0 which makes the transformation redundant.

Any optimization level other than O0 would invoke InstCombine which would
resolve the chain of GEPs into flat base + offset GEP for each store which
does not exhibit the repeated examination of each store to the array.

Disabling this optimization fixes an excessive compile time issue (30~ minutes
for the test case provided) at O0.

Reviewers: niravd, craig.topper, t.p.northover

Differential Revision: https://reviews.llvm.org/D40193

llvm-svn: 319142
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/ARM/alloc-no-stack-realign.ll
llvm/test/CodeGen/Mips/dagcombine-store-gep-chain-slow.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/pr32284.ll
llvm/test/CodeGen/X86/pr32345.ll