Clean up variables before sroa
authorSteven Perron <stevenperron@google.com>
Thu, 22 Feb 2018 17:23:21 +0000 (12:23 -0500)
committerSteven Perron <31666470+s-perron@users.noreply.github.com>
Fri, 23 Feb 2018 02:40:58 +0000 (21:40 -0500)
commit94af58a350b46f85422699e27ccbf22bf453149f
tree6929d99d899dfd5d6d6d56fb4d0a5881d7e1a8ed
parent3f19c2031a8684dce8d28de770d1a7e44c30c0b1
Clean up variables before sroa

In some shaders there are a lot of very large and deeply nested
structures.  This creates a lot of work for scalar replacement.  Also,
since commit ca4457b we have been very aggressive as rewriting
variables.  This has causes a large increase in compile time in creating
and then deleting the instructions.

To help low the costs, I want to run a cleanup of some of the easy loads
and stores to remove.  This reduces the number of symbols sroa has to
work on.  It also reduces the amount of code the simplifier has to
simplify because it was not generated by sroa.

To confirm the improvement, I ran numbers on three different sets of
shaders:

Time to run --legalize-hlsl:

Set #1: 55.89s -> 12.0s
Set #2: 1m44s -> 1m40.5s
Set #3: 6.8s -> 5.7s

Time to run -O

Set #1: 18.8s -> 10.9s
Set #2: 5m44s -> 4m17s
Set #3: 7.8s -> 7.8s

Contributes to #1328.
source/opt/optimizer.cpp