A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Cranelift: mid-end: fix constant types in some icmp/select rules. (#12504)
Chris Fallin9c1f3e82e98d
diff --git a/cranelift/codegen/src/opts/icmp.isle b/cranelift/codegen/src/opts/icmp.isleindex ae56eb4c4c..1621bb5922 100644--- a/cranelift/codegen/src/opts/icmp.isle+++ b/cranelift/codegen/src/opts/icmp.isle@@ -387,33 +387,33 @@;; constants can directly use the inner select condition.;; See: https://github.com/bytecodealliance/wasmtime/issues/11578(rule (simplify (eq _- (select select_ty inner_cond+ (select select_ty inner_cond @ (value_type inner_ty)(iconst_u _ k1)(iconst_u _ k2))(iconst_u _ k1)))(if-let false (u64_eq k1 k2))- (ne select_ty inner_cond (iconst_u select_ty 0)))+ (ne select_ty inner_cond (iconst_u inner_ty 0)))(rule (simplify (eq _- (select select_ty inner_cond+ (select select_ty inner_cond @ (value_type inner_ty)(iconst_u _ k1)(iconst_u _ k2))(iconst_u _ k2)))(if-let false (u64_eq k1 k2))- (eq select_ty inner_cond (iconst_u select_ty 0)))+ (eq select_ty inner_cond (iconst_u inner_ty 0)))(rule (simplify (ne _- (select select_ty inner_cond+ (select select_ty inner_cond @ (value_type inner_ty)(iconst_u _ k1)(iconst_u _ k2))(iconst_u _ k1)))(if-let false (u64_eq k1 k2))- (eq select_ty inner_cond (iconst_u select_ty 0)))+ (eq select_ty inner_cond (iconst_u inner_ty 0)))(rule (simplify (ne _- (select select_ty inner_cond+ (select select_ty inner_cond @ (value_type inner_ty)(iconst_u _ k1)(iconst_u _ k2))(iconst_u _ k2)))(if-let false (u64_eq k1 k2))- (ne select_ty inner_cond (iconst_u select_ty 0)))+ (ne select_ty inner_cond (iconst_u inner_ty 0)))diff --git a/cranelift/filetests/filetests/egraph/issue-11578-opt.clif b/cranelift/filetests/filetests/egraph/issue-11578-opt.clifindex 0d59c41048..b40042c75e 100644--- a/cranelift/filetests/filetests/egraph/issue-11578-opt.clif+++ b/cranelift/filetests/filetests/egraph/issue-11578-opt.clif@@ -43,8 +43,8 @@ block0(v2: i64):; nextln: v14 = iconst.i64 -562949953421310; nextln: v3 = band v2, v14 ; v14 = -562949953421310; nextln: v16 = iconst.i64 0-; nextln: v18 = icmp ne v3, v16 ; v16 = 0-; nextln: return v18+; nextln: v19 = icmp ne v3, v16 ; v16 = 0+; nextln: return v19; nextln: }function %ne_k1(i64) -> i8 {@@ -65,8 +65,8 @@ block0(v2: i64):; nextln: v14 = iconst.i64 -562949953421310; nextln: v3 = band v2, v14 ; v14 = -562949953421310; nextln: v16 = iconst.i64 0-; nextln: v18 = icmp ne v3, v16 ; v16 = 0-; nextln: return v18+; nextln: v19 = icmp ne v3, v16 ; v16 = 0+; nextln: return v19; nextln: }function %ne_k2(i64) -> i8 {diff --git a/cranelift/filetests/filetests/egraph/issue-12503.clif b/cranelift/filetests/filetests/egraph/issue-12503.clifnew file mode 100644index 0000000000..bddeb099b5--- /dev/null+++ b/cranelift/filetests/filetests/egraph/issue-12503.clif@@ -0,0 +1,12 @@+test compile+set opt_level=speed_and_size+target aarch64++function u0:1360(i8) -> i8 system_v {+block0(v0: i8):+ v1 = iconst.i64 0+ v2 = iconst.i64 1+ v3 = select v0, v1, v2+ v4 = icmp_imm eq v3, 1+ return v4+}