A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
[Cranelift] folds selects (#11648)
Bongjun Jang447efbd33007
diff --git a/cranelift/codegen/src/opts/selects.isle b/cranelift/codegen/src/opts/selects.isleindex a80896b615..4ec353c3fb 100644--- a/cranelift/codegen/src/opts/selects.isle+++ b/cranelift/codegen/src/opts/selects.isle@@ -98,3 +98,7 @@(select ty c(iconst ty (imm64_masked ty (u64_wrapping_add x z)))(iconst ty (imm64_masked ty (u64_wrapping_add y z)))))++(rule (simplify (select ty d a (select ty d _ y))) (select ty d a y))+(rule (simplify (select ty d (select ty d x _) a)) (select ty d x a))+diff --git a/cranelift/filetests/filetests/egraph/fold-selects.clif b/cranelift/filetests/filetests/egraph/fold-selects.clifnew file mode 100644index 0000000000..f8e2285c7b--- /dev/null+++ b/cranelift/filetests/filetests/egraph/fold-selects.clif@@ -0,0 +1,30 @@+test optimize precise-output+set opt_level=speed+target x86_64++function %fold_three_selects1(i8, i8, i8, i8, i8) -> i8 {+block0(v0: i8, v1: i8, v2: i8, v3: i8, v4: i8):+ v5 = select v0, v3, v2+ v6 = select v0, v4, v5+ return v6+}++; function %fold_three_selects1(i8, i8, i8, i8, i8) -> i8 fast {+; block0(v0: i8, v1: i8, v2: i8, v3: i8, v4: i8):+; v7 = select v0, v4, v2+; return v7+; }++function %fold_three_selects1(i8, i8, i8, i8, i8) -> i8 {+block0(v0: i8, v1: i8, v2: i8, v3: i8, v4: i8):+ v5 = select v0, v3, v2+ v6 = select v0, v5, v4+ return v6+}++; function %fold_three_selects1(i8, i8, i8, i8, i8) -> i8 fast {+; block0(v0: i8, v1: i8, v2: i8, v3: i8, v4: i8):+; v7 = select v0, v3, v4+; return v7+; }+