Delete old cranelift-preopt crate (#5642)
Most of these optimizations are in the egraph `cprop.isle` rules now, making a separate crate unnecessary. Also I think the `udiv` optimizations here are straight-up wrong (doing signed instead of unsigned division, and panicking instead of preserving traps on division by zero) so I'm guessing this crate isn't seriously used anywhere. At the least, bjorn3 confirms that cg_clif doesn't use this, and I've verified that Wasmtime doesn't either. Closes #1090.
This commit is contained in:
@@ -15,7 +15,6 @@ cranelift-frontend = { workspace = true }
|
||||
cranelift-interpreter = { workspace = true }
|
||||
cranelift-native = { workspace = true }
|
||||
cranelift-reader = { workspace = true }
|
||||
cranelift-preopt = { workspace = true }
|
||||
cranelift-jit = { workspace = true, features = ["selinux-fix"] }
|
||||
cranelift-module = { workspace = true }
|
||||
file-per-thread-logger = "0.1.2"
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
test preopt
|
||||
target aarch64
|
||||
target x86_64
|
||||
|
||||
function %brz_fold() -> i32 {
|
||||
block0:
|
||||
v0 = iconst.i8 0
|
||||
brz v0, block2
|
||||
jump block1
|
||||
block1:
|
||||
v1 = iconst.i32 42
|
||||
return v1
|
||||
block2:
|
||||
v2 = iconst.i32 24
|
||||
return v2
|
||||
}
|
||||
; sameln: function %brz_fold
|
||||
; nextln: block0:
|
||||
; nextln: v0 = iconst.i8 0
|
||||
; nextln: jump block2
|
||||
; nextln:
|
||||
; nextln: block1:
|
||||
; nextln: v1 = iconst.i32 42
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: block2:
|
||||
; nextln: v2 = iconst.i32 24
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
|
||||
function %brnz_fold() -> i32 {
|
||||
block0:
|
||||
v0 = iconst.i8 1
|
||||
brnz v0, block2
|
||||
jump block1
|
||||
block1:
|
||||
v1 = iconst.i32 42
|
||||
return v1
|
||||
block2:
|
||||
v2 = iconst.i32 24
|
||||
return v2
|
||||
}
|
||||
; sameln: function %brnz_fold
|
||||
; nextln: block0:
|
||||
; nextln: v0 = iconst.i8 1
|
||||
; nextln: jump block2
|
||||
; nextln:
|
||||
; nextln: block1:
|
||||
; nextln: v1 = iconst.i32 42
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: block2:
|
||||
; nextln: v2 = iconst.i32 24
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
|
||||
function %brz_fold_param(i8) -> i32 {
|
||||
block0(v0: i8):
|
||||
brz v0, block2
|
||||
jump block1
|
||||
block1:
|
||||
v1 = iconst.i32 42
|
||||
return v1
|
||||
block2:
|
||||
v2 = iconst.i32 24
|
||||
return v2
|
||||
}
|
||||
; sameln: function %brz_fold_param(i8) -> i32 fast {
|
||||
; nextln: block0(v0: i8):
|
||||
; nextln: brz v0, block2
|
||||
; nextln: jump block1
|
||||
; nextln:
|
||||
; nextln: block1:
|
||||
; nextln: v1 = iconst.i32 42
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: block2:
|
||||
; nextln: v2 = iconst.i32 24
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
@@ -1,20 +0,0 @@
|
||||
test preopt
|
||||
target aarch64
|
||||
target x86_64
|
||||
|
||||
function %constant_fold(f64) -> f64 {
|
||||
block0(v0: f64):
|
||||
v1 = f64const 0x1.0000000000000p0
|
||||
v2 = f64const 0x1.0000000000000p1
|
||||
v3 = fadd v1, v2
|
||||
v4 = fadd v3, v0
|
||||
return v4
|
||||
}
|
||||
; sameln: function %constant_fold(f64) -> f64 fast {
|
||||
; nextln: block0(v0: f64):
|
||||
; nextln: v1 = f64const 0x1.0000000000000p0
|
||||
; nextln: v2 = f64const 0x1.0000000000000p1
|
||||
; nextln: v3 = f64const 0x1.8000000000000p1
|
||||
; nextln: v4 = fadd v3, v0
|
||||
; nextln: return v4
|
||||
; nextln: }
|
||||
@@ -1,37 +0,0 @@
|
||||
test preopt
|
||||
target aarch64
|
||||
target x86_64
|
||||
|
||||
function %iadd_fold() -> i32 {
|
||||
block0:
|
||||
v0 = iconst.i32 37
|
||||
v1 = iconst.i32 5
|
||||
v2 = iadd v0, v1
|
||||
v3 = iconst.i32 8
|
||||
v4 = iadd v2, v3
|
||||
return v4
|
||||
}
|
||||
; sameln: function %iadd_fold
|
||||
; nextln: block0:
|
||||
; nextln: v0 = iconst.i32 37
|
||||
; nextln: v1 = iconst.i32 5
|
||||
; nextln: v2 = iconst.i32 42
|
||||
; nextln: v3 = iconst.i32 8
|
||||
; nextln: v4 = iconst.i32 50
|
||||
; nextln: return v4
|
||||
; nextln: }
|
||||
|
||||
function %isub_fold() -> i32 {
|
||||
block0:
|
||||
v0 = iconst.i32 42
|
||||
v1 = iconst.i32 1
|
||||
v2 = isub v0, v1
|
||||
return v2
|
||||
}
|
||||
; sameln: function %isub_fold
|
||||
; nextln: block0:
|
||||
; nextln: v0 = iconst.i32 42
|
||||
; nextln: v1 = iconst.i32 1
|
||||
; nextln: v2 = iconst.i32 41
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
@@ -45,7 +45,6 @@ mod test_interpret;
|
||||
mod test_legalizer;
|
||||
mod test_licm;
|
||||
mod test_optimize;
|
||||
mod test_preopt;
|
||||
mod test_print_cfg;
|
||||
mod test_run;
|
||||
mod test_safepoint;
|
||||
@@ -122,7 +121,6 @@ fn new_subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn subtest::SubTest>
|
||||
"legalizer" => test_legalizer::subtest(parsed),
|
||||
"licm" => test_licm::subtest(parsed),
|
||||
"optimize" => test_optimize::subtest(parsed),
|
||||
"preopt" => test_preopt::subtest(parsed),
|
||||
"print-cfg" => test_print_cfg::subtest(parsed),
|
||||
"run" => test_run::subtest(parsed),
|
||||
"safepoint" => test_safepoint::subtest(parsed),
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
//! Test command for testing the constant folding pass.
|
||||
//!
|
||||
//! The `dce` test command runs each function through the constant folding pass after ensuring
|
||||
//! that all instructions are legal for the target.
|
||||
//!
|
||||
//! The resulting function is sent to `filecheck`.
|
||||
|
||||
use crate::subtest::{run_filecheck, Context, SubTest};
|
||||
use cranelift_codegen;
|
||||
use cranelift_codegen::ir::Function;
|
||||
use cranelift_preopt::optimize;
|
||||
use cranelift_reader::TestCommand;
|
||||
use std::borrow::Cow;
|
||||
|
||||
struct TestPreopt;
|
||||
|
||||
pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {
|
||||
assert_eq!(parsed.command, "preopt");
|
||||
if !parsed.options.is_empty() {
|
||||
anyhow::bail!("No options allowed on {}", parsed);
|
||||
}
|
||||
Ok(Box::new(TestPreopt))
|
||||
}
|
||||
|
||||
impl SubTest for TestPreopt {
|
||||
fn name(&self) -> &'static str {
|
||||
"preopt"
|
||||
}
|
||||
|
||||
fn is_mutating(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn needs_isa(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {
|
||||
let isa = context.isa.expect("compile needs an ISA");
|
||||
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
|
||||
|
||||
optimize(&mut comp_ctx, isa)
|
||||
.map_err(|e| crate::pretty_anyhow_error(&comp_ctx.func, Into::into(e)))?;
|
||||
|
||||
let text = comp_ctx.func.display().to_string();
|
||||
run_filecheck(&text, context)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user