diff options
author | Steven Perron <stevenperron@google.com> | 2018-02-15 12:14:39 -0500 |
---|---|---|
committer | Steven Perron <stevenperron@google.com> | 2018-02-16 20:46:49 -0500 |
commit | 04cd63e5b9c81b39906692cc635acfa2f4e1729f (patch) | |
tree | 975f90fc2da5c621ea509ecb41adbeba14b5a744 /source/opt | |
parent | 105441360043248e91ec1c8b981f9541dab11083 (diff) | |
download | SPIRV-Tools-04cd63e5b9c81b39906692cc635acfa2f4e1729f.tar.gz SPIRV-Tools-04cd63e5b9c81b39906692cc635acfa2f4e1729f.tar.bz2 SPIRV-Tools-04cd63e5b9c81b39906692cc635acfa2f4e1729f.zip |
Make better use of simplification pass
The simplification pass works better after all of the dead branches are
removed. So swapping them around in the legalization passes. Also
adding the simplification pass to performance passes right after dead
branch elimination.
Added CCP to the legalization passes so we can propagate the constants
into the branchs, and remove as many branches a possible. CCP is
designed to still get opportunities even if the branches are dead, so it
is a good place for it.
Fixes #1118
Diffstat (limited to 'source/opt')
-rw-r--r-- | source/opt/optimizer.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/opt/optimizer.cpp b/source/opt/optimizer.cpp index 8aed7bc1..e697e436 100644 --- a/source/opt/optimizer.cpp +++ b/source/opt/optimizer.cpp @@ -102,12 +102,15 @@ Optimizer& Optimizer::RegisterLegalizationPasses() { .RegisterPass(CreateLocalSingleBlockLoadStoreElimPass()) .RegisterPass(CreateLocalSingleStoreElimPass()) .RegisterPass(CreateLocalMultiStoreElimPass()) + // Propagate constants to get as many constant conditions on branches + // as possible. + .RegisterPass(CreateCCPPass()) + .RegisterPass(CreateDeadBranchElimPass()) // Copy propagate members. Cleans up code sequences generated by - // scalar replacement. + // scalar replacement. Also important for removing OpPhi nodes. .RegisterPass(CreateSimplificationPass()) // May need loop unrolling here see // https://github.com/Microsoft/DirectXShaderCompiler/pull/930 - .RegisterPass(CreateDeadBranchElimPass()) // Get rid of unused code that contain traces of illegal code // or unused references to unbound external objects .RegisterPass(CreateDeadInsertElimPass()) @@ -130,6 +133,7 @@ Optimizer& Optimizer::RegisterPerformancePasses() { .RegisterPass(CreateInsertExtractElimPass()) .RegisterPass(CreateDeadInsertElimPass()) .RegisterPass(CreateDeadBranchElimPass()) + .RegisterPass(CreateSimplificationPass()) .RegisterPass(CreateIfConversionPass()) .RegisterPass(CreateAggressiveDCEPass()) .RegisterPass(CreateBlockMergePass()) |