diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2018-12-01 18:28:52 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2018-12-04 10:14:29 -0800 |
commit | e6048c1dabde9e511d25c8bd6d2da68461807f74 (patch) | |
tree | 08f5d4d4fbf5586f602bcab90a72aa288ec72ad1 /test/debugInfo.fromasm.imprecise | |
parent | 774768375dbe8cdee91b797f1e8deec586085fb4 (diff) | |
download | binaryen-e6048c1dabde9e511d25c8bd6d2da68461807f74.tar.gz binaryen-e6048c1dabde9e511d25c8bd6d2da68461807f74.tar.bz2 binaryen-e6048c1dabde9e511d25c8bd6d2da68461807f74.zip |
Speculate in simplify-locals that it is worth turning an if into
an if-else.
If an if sets a local,
(if
(..condition..)
(set_local $x (..value..))
)
we can turn it into
(set_local $x
(if
(..condition..)
(..value..)
(get_local $x)
)
)
This increases code size and adds a branch in the if, but allows
the set to be optimized into a tee or optimized out entirely. In
the worst case, other optimizations can break up an if with a copy
in one of its arms later.
Includes a determinism fix for EquivalentSets, which this patch
triggered.
Diffstat (limited to 'test/debugInfo.fromasm.imprecise')
-rw-r--r-- | test/debugInfo.fromasm.imprecise | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/test/debugInfo.fromasm.imprecise b/test/debugInfo.fromasm.imprecise index f8734889f..b4d624e89 100644 --- a/test/debugInfo.fromasm.imprecise +++ b/test/debugInfo.fromasm.imprecise @@ -118,41 +118,36 @@ (set_local $1 (block $__rjto$0 (result i32) (block $__rjti$0 - (br $__rjto$0 - (if (result i32) - (i32.lt_s - (tee_local $1 - (i32.add - (get_local $0) - (i32.const 52) - ) + (if + (i32.lt_s + (tee_local $1 + (i32.add + (get_local $0) + (i32.const 52) ) - (i32.const 1369188723) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const -1108210269) - ) - ) + (i32.const 1369188723) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const -1108210269) ) - (i32.const 0) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const 1369188723) - ) - ) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const 1369188723) ) - (i32.const 0) ) ) ) + (br $__rjto$0 + (i32.const 0) + ) ) (call $switch_reach (get_local $0) |