LICM pass (#87)

* LICM pass

* Uses loop analysis to detect loop tree
* For each loop (starting with the inner ones), create a pre-header and move there loop-invariant instructions
* An instruction is loop invariant if it does not use as argument a value defined earlier in the loop
* File tests to check LICM's correctness
* Optimized pre-header creation
If the loop already has a natural pre-header, we use it instead of creating a new one.
The natural pre-header of a loop is the only predecessor of the header it doesn't dominate.
This commit is contained in:
Denis Merigoux
2017-06-07 11:27:22 -07:00
committed by Jakob Stoklund Olesen
parent 402cb8e1f6
commit e47f4a49fb
10 changed files with 487 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ use regalloc;
use result::CtonResult;
use verifier;
use simple_gvn::do_simple_gvn;
use licm::do_licm;
/// Persistent data structures and compilation pipeline.
pub struct Context {
@@ -92,6 +93,15 @@ impl Context {
self.verify(None).map_err(Into::into)
}
/// Perform LICM on the function.
pub fn licm(&mut self) -> CtonResult {
do_licm(&mut self.func,
&mut self.cfg,
&mut self.domtree,
&mut self.loop_analysis);
self.verify(None).map_err(Into::into)
}
/// Run the register allocator.
pub fn regalloc(&mut self, isa: &TargetIsa) -> CtonResult {
self.regalloc