diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-05-10 08:58:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 08:58:09 -0700 |
commit | 111b4f1950467d51a78211af183f4ae6398aac49 (patch) | |
tree | 7f53ab6389e2bcaacf761cbf33846ac0210bd098 /test/passes/simplify-locals.wast | |
parent | 6a9ececa2fc9eca99a12b65ca130612942babdce (diff) | |
download | binaryen-111b4f1950467d51a78211af183f4ae6398aac49.tar.gz binaryen-111b4f1950467d51a78211af183f4ae6398aac49.tar.bz2 binaryen-111b4f1950467d51a78211af183f4ae6398aac49.zip |
Optimize equivalent locals (#1540)
If locals are known to contain the same value, we can
* Pick which local to use for a get_local of any of them. Makes sense to prefer the most common, to increase the chance of one dropping to zero uses.
* Remove copies between a local and one that we know contains the same value.
This is a consistent win, small though, around 0.1-0.2%.
Diffstat (limited to 'test/passes/simplify-locals.wast')
-rw-r--r-- | test/passes/simplify-locals.wast | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast index 3d82fe0a4..d8d5ff7a6 100644 --- a/test/passes/simplify-locals.wast +++ b/test/passes/simplify-locals.wast @@ -1129,4 +1129,102 @@ ) (i32.const 0) ) + + (func $pick + (local $x i32) + (local $y i32) + (set_local $x (get_local $y)) + (if (i32.const 1) + (set_local $x (i32.const 1)) + ) + (set_local $x (get_local $y)) + (set_local $x (get_local $y)) + ) + (func $pick-2 + (local $x i32) + (local $y i32) + (set_local $y (get_local $x)) + (if (i32.const 1) + (set_local $y (i32.const 1)) + ) + (set_local $y (get_local $x)) + (set_local $y (get_local $x)) + ) + (func $many + (local $x i32) + (local $y i32) + (local $z i32) + (local $w i32) + (set_local $y (get_local $x)) + (set_local $z (get_local $y)) + (set_local $w (get_local $z)) + (set_local $x (get_local $z)) + (if (i32.const 1) + (set_local $y (i32.const 1)) + ) + (set_local $x (get_local $z)) + (if (i32.const 1) + (set_local $y (i32.const 1)) + ) + (set_local $y (get_local $x)) + (set_local $z (get_local $y)) + (set_local $w (get_local $z)) + (set_local $z (i32.const 2)) + (set_local $x (get_local $z)) + (if (i32.const 1) + (set_local $y (i32.const 1)) + ) + (set_local $y (get_local $x)) + (set_local $z (get_local $y)) + (set_local $w (get_local $z)) + (set_local $z (i32.const 2)) + (set_local $x (get_local $w)) + ) + (func $loop-copies (param $x i32) (param $y i32) + (loop $loop + (set_local $x (get_local $y)) + (set_local $y (get_local $x)) + (br_if $loop (get_local $x)) + ) + ) + (func $proper-type (result f64) + (local $var$0 i32) + (local $var$2 f64) + (set_local $var$0 + (select + (i32.const 0) + (i32.const 1) + (get_local $var$0) + ) + ) + (tee_local $var$2 + (get_local $var$2) + ) + ) + (func $multi-pass-get-equivs-right (param $var$0 i32) (param $var$1 i32) (result f64) + (local $var$2 i32) + (set_local $var$2 + (get_local $var$0) + ) + (i32.store + (get_local $var$2) + (i32.const 1) + ) + (f64.promote/f32 + (f32.load + (get_local $var$2) + ) + ) + ) + (func $if-value-structure-equivalent (param $x i32) (result i32) + (local $y i32) + (if (i32.const 1) + (set_local $x (i32.const 2)) + (block + (set_local $y (get_local $x)) + (set_local $x (get_local $y)) + ) + ) + (get_local $x) + ) ) |