A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
[ISLE] add opt and tests (#11555)
Bongjun Jangdeed903d2b23
diff --git a/cranelift/codegen/src/opts/bitops.isle b/cranelift/codegen/src/opts/bitops.isleindex b3069ca34e..83800dba2f 100644--- a/cranelift/codegen/src/opts/bitops.isle+++ b/cranelift/codegen/src/opts/bitops.isle@@ -191,3 +191,9 @@(bswap ty x))(rule (simplify (bxor ty (bor ty x y) (band ty x y))) (bxor ty x y))+++(rule (simplify (bor ty (bor ty x y) x)) (bor ty x y))+(rule (simplify (bor ty (bor ty x y) y)) (bor ty x y))+(rule (simplify (bor ty x (bor ty x y))) (bor ty x y))+(rule (simplify (bor ty y (bor ty x y))) (bor ty x y))diff --git a/cranelift/filetests/filetests/egraph/fold-bitops.clif b/cranelift/filetests/filetests/egraph/fold-bitops.clifnew file mode 100644index 0000000000..3026bc98f0--- /dev/null+++ b/cranelift/filetests/filetests/egraph/fold-bitops.clif@@ -0,0 +1,60 @@+test optimize precise-output+set opt_level=speed+target x86_64++;; (rule (simplify (bor ty x (bor ty x y))) (bor ty x y))+function %simplify_bor_xxy(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v2 = bor v0, v1+ v3 = bor v0, v2+ return v3+}++; function %simplify_bor_xxy(i32, i32) -> i32 fast {+; block0(v0: i32, v1: i32):+; v2 = bor v0, v1+; return v2+; }++;; (rule (simplify (bor ty y (bor ty x y))) (bor ty x y))+function %simplify_bor_yxy(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v3 = bor v0, v1+ v4 = bor v1, v3+ return v4+}++; function %simplify_bor_yxy(i32, i32) -> i32 fast {+; block0(v0: i32, v1: i32):+; v3 = bor v0, v1+; return v3+; }++;; (rule (simplify (bor ty (bor ty x y) x)) (bor ty x y))+function %simplify_bor_xyx(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v2 = bor v0, v1+ v3 = bor v2, v0+ return v3+}++; function %simplify_bor_xyx(i32, i32) -> i32 fast {+; block0(v0: i32, v1: i32):+; v2 = bor v0, v1+; return v2+; }++;; (rule (simplify (bor ty (bor ty x y) y)) (bor ty x y))+function %simplify_bor_xyy(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v2 = bor v0, v1+ v3 = bor v2, v1+ return v3+}++; function %simplify_bor_xyy(i32, i32) -> i32 fast {+; block0(v0: i32, v1: i32):+; v2 = bor v0, v1+; return v2+; }+diff --git a/cranelift/filetests/filetests/runtests/fold-bitops.clif b/cranelift/filetests/filetests/runtests/fold-bitops.clifnew file mode 100644index 0000000000..03806b2896--- /dev/null+++ b/cranelift/filetests/filetests/runtests/fold-bitops.clif@@ -0,0 +1,66 @@+test interpret+test run+set opt_level=none+target aarch64+target s390x+target riscv64+target riscv64 has_c has_zcb+target s390x has_mie3+target x86_64+target pulley32+target pulley32be+target pulley64+target pulley64be++set opt_level=speed+target aarch64+target s390x+target riscv64+target riscv64 has_c has_zcb+target s390x has_mie3+target x86_64+target pulley32+target pulley32be+target pulley64+target pulley64be+++function %simplify_bor_xxy(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v2 = bor v0, v1+ v3 = bor v0, v2+ return v3+}++; run: %simplify_bor_xxy(1, 2) == 3+; run: %simplify_bor_xxy(54, 9) == 63++function %simplify_bor_yxy(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v3 = bor v0, v1+ v4 = bor v1, v3+ return v4+}++; run: %simplify_bor_yxy(1, 2) == 3+; run: %simplify_bor_yxy(54, 9) == 63++function %simplify_bor_xyx(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v2 = bor v0, v1+ v3 = bor v2, v0+ return v3+}++; run: %simplify_bor_xyx(1, 2) == 3+; run: %simplify_bor_xyx(54, 9) == 63++function %simplify_bor_xyy(i32, i32) -> i32 {+block0(v0: i32, v1: i32):+ v2 = bor v0, v1+ v3 = bor v2, v1+ return v3+}++; run: %simplify_bor_xyy(1, 2) == 3+; run: %simplify_bor_xyy(54, 9) == 63\ No newline at end of file