[JIT] Run the SimplificationPass/ConstantPropagationPass until there are no changes.

This commit is contained in:
gibbed
2018-11-23 11:59:29 -06:00
parent b121f45c7f
commit 5fbcb8991e
10 changed files with 348 additions and 36 deletions

View File

@@ -53,15 +53,16 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::ContextPromotionPass>());
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
// TODO(gibbed): loop until these passes stop making changes?
for (int i = 0; i < 5; ++i) {
compiler_->AddPass(std::make_unique<passes::SimplificationPass>());
if (validate)
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::make_unique<passes::ConstantPropagationPass>());
if (validate)
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
}
// Grouped simplification + constant propagation.
// Loops until no changes are made.
auto sap = std::make_unique<passes::ConditionalGroupPass>();
sap->AddPass(std::make_unique<passes::SimplificationPass>());
if (validate) sap->AddPass(std::make_unique<passes::ValidationPass>());
sap->AddPass(std::make_unique<passes::ConstantPropagationPass>());
if (validate) sap->AddPass(std::make_unique<passes::ValidationPass>());
compiler_->AddPass(std::move(sap));
if (backend->machine_info()->supports_extended_load_store) {
// Backend supports the advanced LOAD/STORE instructions.
// These will save us a lot of HIR opcodes.