* Cranelift: remove non-egraphs optimization pipeline and `use_egraphs` option. This PR removes the LICM, GVN, and preopt passes, and associated support pieces, from `cranelift-codegen`. Not to worry, we still have optimizations: the egraph framework subsumes all of these, and has been on by default since #5181. A few decision points: - Filetests for the legacy LICM, GVN and simple_preopt were removed too. As we built optimizations in the egraph framework we wrote new tests for the equivalent functionality, and many of the old tests were testing specific behaviors in the old implementations that may not be relevant anymore. However if folks prefer I could take a different approach here and try to port over all of the tests. - The corresponding filetest modes (commands) were deleted too. The `test alias_analysis` mode remains, but no longer invokes a separate GVN first (since there is no separate GVN that will not also do alias analysis) so the tests were tweaked slightly to work with that. The egrpah testsuite also covers alias analysis. - The `divconst_magic_numbers` module is removed since it's unused without `simple_preopt`, though this is the one remaining optimization we still need to build in the egraphs framework, pending #5908. The magic numbers will live forever in git history so removing this in the meantime is not a major issue IMHO. - The `use_egraphs` setting itself was removed at both the Cranelift and Wasmtime levels. It has been marked deprecated for a few releases now (Wasmtime 6.0, 7.0, upcoming 8.0, and corresponding Cranelift versions) so I think this is probably OK. As an alternative if anyone feels strongly, we could leave the setting and make it a no-op. * Update test outputs for remaining test differences.
155 lines
3.0 KiB
Plaintext
155 lines
3.0 KiB
Plaintext
test optimize
|
|
set opt_level=speed
|
|
target x86_64
|
|
target aarch64
|
|
target s390x
|
|
target riscv64
|
|
|
|
function %select_sgt_to_smax(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp sgt v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = smax v0, v1
|
|
; check: return v4
|
|
|
|
|
|
; This tests an inverted select, where the operands are swapped.
|
|
function %select_sgt_to_smax_inverse(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp sgt v0, v1
|
|
v3 = select v2, v1, v0
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = smin v0, v1
|
|
; check: return v4
|
|
|
|
|
|
function %select_sge_to_smax(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp sge v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = smax v0, v1
|
|
; check: return v4
|
|
|
|
|
|
function %select_ugt_to_umax(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp ugt v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = umax v0, v1
|
|
; check: return v4
|
|
|
|
|
|
function %select_uge_to_umax(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp uge v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = umax v0, v1
|
|
; check: return v4
|
|
|
|
|
|
|
|
function %select_slt_to_smin(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp slt v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = smin v0, v1
|
|
; check: return v4
|
|
|
|
|
|
function %select_sle_to_smin(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp sle v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = smin v0, v1
|
|
; check: return v4
|
|
|
|
|
|
function %select_ult_to_umin(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp ult v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = umin v0, v1
|
|
; check: return v4
|
|
|
|
|
|
function %select_ule_to_umin(i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32):
|
|
v2 = icmp ule v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32):
|
|
; check: v4 = umin v0, v1
|
|
; check: return v4
|
|
|
|
|
|
|
|
function %select_with_different_regs_does_not_optimize(i32, i32, i32, i32) -> i32 {
|
|
block0(v0: i32, v1: i32, v2: i32, v3: i32):
|
|
v4 = icmp ule v0, v1
|
|
v5 = select v4, v2, v3
|
|
return v5
|
|
}
|
|
|
|
; check: block0(v0: i32, v1: i32, v2: i32, v3: i32):
|
|
; check: v4 = icmp ule v0, v1
|
|
; check: v5 = select v4, v2, v3
|
|
; check: return v5
|
|
|
|
|
|
|
|
|
|
function %select_fcmp_gt_to_fmax_pseudo(f32, f32) -> f32 {
|
|
block0(v0: f32, v1: f32):
|
|
v2 = fcmp gt v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: f32, v1: f32):
|
|
; check: v4 = fmax_pseudo v0, v1
|
|
; check: return v4
|
|
|
|
function %select_fcmp_lt_to_fmin_pseudo(f32, f32) -> f32 {
|
|
block0(v0: f32, v1: f32):
|
|
v2 = fcmp lt v0, v1
|
|
v3 = select v2, v0, v1
|
|
return v3
|
|
}
|
|
|
|
; check: block0(v0: f32, v1: f32):
|
|
; check: v4 = fmin_pseudo v0, v1
|
|
; check: return v4
|