Issue 311 - Add a pass to make NaN bits deterministic. (#322)

This commit is contained in:
pup
2018-05-09 16:11:58 -04:00
committed by Dan Gohman
parent f636d795c5
commit b36fc6b75f
6 changed files with 105 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ use isa::TargetIsa;
use legalize_function;
use licm::do_licm;
use loop_analysis::LoopAnalysis;
use nan_canonicalization::do_nan_canonicalization;
use postopt::do_postopt;
use preopt::do_preopt;
use regalloc;
@@ -124,6 +125,9 @@ impl Context {
if isa.flags().opt_level() != OptLevel::Fastest {
self.preopt(isa)?;
}
if isa.flags().enable_nan_canonicalization() {
self.canonicalize_nans(isa)?;
}
self.legalize(isa)?;
if isa.flags().opt_level() != OptLevel::Fastest {
self.postopt(isa)?;
@@ -212,6 +216,12 @@ impl Context {
Ok(())
}
/// Perform NaN canonicalizing rewrites on the function.
pub fn canonicalize_nans(&mut self, isa: &TargetIsa) -> CtonResult {
do_nan_canonicalization(&mut self.func);
self.verify_if(isa)
}
/// Run the legalizer for `isa` on the function.
pub fn legalize(&mut self, isa: &TargetIsa) -> CtonResult {
// Legalization invalidates the domtree and loop_analysis by mutating the CFG.