Add a transformation pass which removes phi nodes to which it can demonstrate

that only one value ever flows.  Has been observed to improve generated code
run times by up to 8%.  Compilation cost increases by about 0.6%, but up to 7%
total cost has been observed to be saved; iow it can be a significant win in
terms of compilation time, overall.
This commit is contained in:
Julian Seward
2020-05-06 09:08:14 +02:00
committed by julian-seward1
parent b65bd1c8a2
commit 0bc0503f3f
4 changed files with 408 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ use crate::nan_canonicalization::do_nan_canonicalization;
use crate::postopt::do_postopt;
use crate::redundant_reload_remover::RedundantReloadRemover;
use crate::regalloc;
use crate::remove_constant_phis::do_remove_constant_phis;
use crate::result::CodegenResult;
use crate::settings::{FlagsOrIsa, OptLevel};
use crate::simple_gvn::do_simple_gvn;
@@ -179,6 +180,8 @@ impl Context {
self.dce(isa)?;
}
self.remove_constant_phis(isa)?;
if let Some(backend) = isa.get_mach_backend() {
let result = backend.compile_function(&self.func, self.want_disasm)?;
let info = result.code_info();
@@ -292,6 +295,16 @@ impl Context {
Ok(())
}
/// Perform constant-phi removal on the function.
pub fn remove_constant_phis<'a, FOI: Into<FlagsOrIsa<'a>>>(
&mut self,
fisa: FOI,
) -> CodegenResult<()> {
do_remove_constant_phis(&mut self.func, &mut self.domtree);
self.verify_if(fisa)?;
Ok(())
}
/// Perform pre-legalization rewrites on the function.
pub fn preopt(&mut self, isa: &dyn TargetIsa) -> CodegenResult<()> {
do_preopt(&mut self.func, &mut self.cfg, isa);