Remove uses DCEInst and call ADCE
authorSteven Perron <stevenperron@google.com>
Thu, 22 Feb 2018 21:05:37 +0000 (16:05 -0500)
committerSteven Perron <31666470+s-perron@users.noreply.github.com>
Wed, 28 Feb 2018 02:06:08 +0000 (21:06 -0500)
commit2cb589cc14ac68c5769d3a70ce10d2917885121e
tree333b09cd5304df6e76daae01724b0962953c0a06
parent0c13467161842389a5270e5a0e2a6c9e9be487a5
Remove uses DCEInst and call ADCE

The algorithm used in DCEInst to remove dead code is very slow.  It is
fine if you only want to remove a small number of instructions, but, if
you need to remove a large number of instructions, then the algorithm in
ADCE is much faster.

This PR removes the calls to DCEInst in the load-store removal passes
and adds a pass of ADCE afterwards.

A number of different iterations of the order of optimization, and I
believe this is the best I could find.

The results I have on 3 sets of shaders are:

Legalization:

Set 1: 5.39 -> 5.01
Set 2: 13.98 -> 8.38
Set 3: 98.00 -> 96.26

Performance passes:

Set 1: 6.90 -> 5.23
Set 2: 10.11 -> 6.62
Set 3: 253.69 -> 253.74

Size reduction passes:

Set 1: 7.16 -> 7.25
Set 2: 17.17 -> 16.81
Set 3: 112.06 -> 107.71

Note that the third set's compile time is large because of the large
number of basic blocks, not so much because of the number of
instructions.  That is why we don't see much gain there.
source/opt/local_single_block_elim_pass.cpp
source/opt/local_single_store_elim_pass.cpp
source/opt/local_single_store_elim_pass.h
source/opt/local_ssa_elim_pass.cpp
source/opt/local_ssa_elim_pass.h
source/opt/mem_pass.cpp
source/opt/mem_pass.h
source/opt/optimizer.cpp
test/opt/local_single_block_elim.cpp
test/opt/local_single_store_elim_test.cpp
test/opt/local_ssa_elim_test.cpp