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
This commit is contained in:
Steven Perron 2018-02-15 12:14:39 -05:00
parent 1054413600
commit 04cd63e5b9

View File

@ -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())