diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-11-27 09:26:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-27 09:26:29 -0800 |
commit | 70b949ffdc3e5f3fa83dd4044f632c95159674cf (patch) | |
tree | c2bb05065cd082305cad594e76a169d1a8005a9a /test/passes/optimize-instructions.wast | |
parent | 69c93dd9fb4cf8081237c4303a416bf12dff6b58 (diff) | |
download | binaryen-70b949ffdc3e5f3fa83dd4044f632c95159674cf.tar.gz binaryen-70b949ffdc3e5f3fa83dd4044f632c95159674cf.tar.bz2 binaryen-70b949ffdc3e5f3fa83dd4044f632c95159674cf.zip |
Stricter Canonicalization (#1774)
In OptimizeInstructions we canonicalized a const on the right side. This PR adds further canonicalization, of a get to the right, and of sorting by binary and unary op ids. This guarantees fixed orders for small combinations of instructions that can then be pattern-matched in a simple way in future PRs.
Diffstat (limited to 'test/passes/optimize-instructions.wast')
-rw-r--r-- | test/passes/optimize-instructions.wast | 111 |
1 files changed, 110 insertions, 1 deletions
diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index 9ab5127a3..234b3913b 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -283,11 +283,120 @@ (drop (i32.and (i32.const 100) (i32.const 1))) (drop (i32.and (i32.lt_s (i32.const 2000) (i32.const 3000)) (i32.const 1))) ) - (func $canonicalize-binary + (func $canonicalize (param $x i32) (param $y i32) (param $fx f64) (param $fy f64) (drop (i32.and (unreachable) (i32.const 1))) ;; ok to reorder (drop (i32.and (i32.const 1) (unreachable))) (drop (i32.div_s (unreachable) (i32.const 1))) ;; not ok (drop (i32.div_s (i32.const 1) (unreachable))) + ;; the various orderings + (drop (i32.and (i32.const 1) (i32.const 2))) + (drop (i32.and (get_local $x) (i32.const 3))) + (drop (i32.and (i32.const 4) (get_local $x))) + (drop (i32.and (get_local $x) (get_local $y))) + (drop (i32.and (get_local $y) (get_local $x))) + (drop (i32.and (get_local $y) (tee_local $x (i32.const -4)))) + (drop (i32.and + (block (result i32) + (i32.const -5) + ) + (get_local $x) + )) + (drop (i32.and + (get_local $x) + (block (result i32) + (i32.const -6) + ) + )) + (drop (i32.and + (block (result i32) + (i32.const 5) + ) + (loop (result i32) + (i32.const 6) + ) + )) + (drop (i32.and + (loop (result i32) + (i32.const 7) + ) + (block (result i32) + (i32.const 8) + ) + )) + (drop (i32.and + (loop (result i32) + (call $and-pos1) + (i32.const 9) + ) + (block (result i32) + (i32.const 10) + ) + )) + (drop (i32.and + (loop (result i32) + (i32.const 11) + ) + (block (result i32) + (call $and-pos1) + (i32.const 12) + ) + )) + (drop (i32.and + (loop (result i32) + (call $and-pos1) + (i32.const 13) + ) + (block (result i32) + (call $and-pos1) + (i32.const 14) + ) + )) + (drop (i32.and + (block (result i32) + (call $and-pos1) + (i32.const 14) + ) + (loop (result i32) + (call $and-pos1) + (i32.const 13) + ) + )) + (drop (i32.and + (block (result i32) + (i32.const 15) + ) + (get_local $x) + )) + (drop (i32.and + (get_local $x) + (block (result i32) + (i32.const 15) + ) + )) + (drop (i32.and + (i32.gt_s + (i32.const 16) + (i32.const 17) + ) + (i32.gt_u + (i32.const 18) + (i32.const 19) + ) + )) + (drop (i32.and + (i32.gt_u + (i32.const 20) + (i32.const 21) + ) + (i32.gt_s + (i32.const 22) + (i32.const 23) + ) + )) + (drop (i32.add (i32.ctz (get_local $x)) (i32.ctz (get_local $y)))) + (drop (i32.add (i32.ctz (get_local $y)) (i32.ctz (get_local $x)))) + (drop (i32.add (i32.ctz (get_local $x)) (i32.eqz (get_local $y)))) + (drop (i32.add (i32.eqz (get_local $x)) (i32.ctz (get_local $y)))) ) (func $ne0 (result i32) (if (i32.ne (call $ne0) (i32.const 0)) |