diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-06-04 15:31:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-04 15:31:18 -0700 |
commit | bfae82fc4107a8115b41db4a2bd3d9204a92ad16 (patch) | |
tree | f6101330c153057113c7e34e16dc4ed245b73850 | |
parent | 240c6bbe07602ccfcf094e7e47ff7a3f3635229b (diff) | |
download | binaryen-bfae82fc4107a8115b41db4a2bd3d9204a92ad16.tar.gz binaryen-bfae82fc4107a8115b41db4a2bd3d9204a92ad16.tar.bz2 binaryen-bfae82fc4107a8115b41db4a2bd3d9204a92ad16.zip |
run precompute-propagate early, when we would run it also late, as it is helpful in both positions on general code (#1581)
-rw-r--r-- | src/passes/pass.cpp | 9 | ||||
-rw-r--r-- | test/passes/Oz.txt | 5 | ||||
-rw-r--r-- | test/passes/converge_O3_metrics.bin.txt | 257 |
3 files changed, 11 insertions, 260 deletions
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 383752198..6c2aa3731 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -141,7 +141,12 @@ void PassRunner::addDefaultFunctionOptimizationPasses() { if (options.optimizeLevel >= 2 || options.shrinkLevel >= 2) { add("pick-load-signs"); } - add("precompute"); + // early propagation + if (options.optimizeLevel >= 3 || options.shrinkLevel >= 2) { + add("precompute-propagate"); + } else { + add("precompute"); + } if (options.optimizeLevel >= 2 || options.shrinkLevel >= 2) { add("code-pushing"); } @@ -164,7 +169,7 @@ void PassRunner::addDefaultFunctionOptimizationPasses() { add("remove-unused-brs"); // coalesce-locals opens opportunities for optimizations add("merge-blocks"); // clean up remove-unused-brs new blocks add("optimize-instructions"); - // if we are willing to work hard, also propagate + // late propagation if (options.optimizeLevel >= 3 || options.shrinkLevel >= 2) { add("precompute-propagate"); } else { diff --git a/test/passes/Oz.txt b/test/passes/Oz.txt index 4ba8d8088..c0f5252e6 100644 --- a/test/passes/Oz.txt +++ b/test/passes/Oz.txt @@ -31,10 +31,7 @@ (i32.load (get_local $2) ) - (i32.xor - (i32.const 74) - (i32.const -1) - ) + (i32.const -75) ) ) (i32.store diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt index 452c2378d..47e01cdbe 100644 --- a/test/passes/converge_O3_metrics.bin.txt +++ b/test/passes/converge_O3_metrics.bin.txt @@ -2,259 +2,8 @@ total [funcs] : 9 [memory-data] : 28 [table-data] : 429 - [total] : 137 - [vars] : 5 - binary : 12 - block : 9 - break : 3 - call : 3 - call_import : 1 - call_indirect : 4 - const : 48 - drop : 3 - get_global : 1 - get_local : 20 - if : 3 - load : 16 - loop : 1 - set_global : 1 - set_local : 7 - store : 5 -(module - (type $0 (func (param i32 i32) (result i32))) - (type $1 (func (param i32 i32 i32) (result i32))) - (type $2 (func (param i32) (result i32))) - (type $3 (func (param i32))) - (type $6 (func (param i32 i32 i32 i32 i32 i32 i32) (result i32))) - (type $7 (func (result i32))) - (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 478 478 anyfunc)) - (import "env" "___syscall146" (func $import$0 (param i32 i32) (result i32))) - (global $global$0 (mut i32) (i32.const 1)) - (elem (i32.const 0) $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $___stdout_write $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $__ZNSt3__211__stdoutbufIcE6xsputnEPKci $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0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 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $b0 $__ZNSt3__211__stdoutbufIcE8overflowEi) - (data (i32.const 2948) "\03") - (data (i32.const 6828) "\04") - (data (i32.const 7028) "\0d\00\00\00\06") - (data (i32.const 10888) "hello, world!") - (data (i32.const 18100) "\b8\1a") - (data (i32.const 18128) ",I") - (data (i32.const 18732) "D\1b") - (data (i32.const 18764) "`\0b") - (export "_main" (func $_main)) - (export "_malloc" (func $_malloc)) - (func $b0 (; 1 ;) (type $6) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) (param $6 i32) (result i32) - (i32.const 0) - ) - (func $_malloc (; 2 ;) (type $2) (param $0 i32) (result i32) - (i32.const 0) - ) - (func $___stdio_write (; 3 ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (i32.store - (i32.const 8) - (get_local $1) - ) - (i32.store - (i32.const 12) - (get_local $2) - ) - (i32.store - (tee_local $1 - (get_global $global$0) - ) - (i32.const 1) - ) - (i32.store offset=8 - (get_local $1) - (i32.const 2) - ) - (drop - (if (result i32) - (call $import$0 - (i32.const 146) - (get_local $1) - ) - (i32.const -1) - (i32.const 0) - ) - ) - (i32.const 1) - ) - (func $_main (; 4 ;) (type $7) (result i32) - (local $0 i32) - (local $1 i32) - (call $__ZNSt3__224__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_j - (block (result i32) - (set_local $1 - (tee_local $0 - (i32.const 10888) - ) - ) - (loop $label$3 - (br_if $label$3 - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ) - ) - ) - (i32.sub - (get_local $0) - (i32.const 10888) - ) - ) - ) - (call $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc - (i32.const 10) - ) - (i32.const 0) - ) - (func $___stdout_write (; 5 ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (set_global $global$0 - (i32.const 32) - ) - (call $___stdio_write - (i32.const 1) - (get_local $1) - (get_local $2) - ) - ) - (func $__ZNSt3__224__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_j (; 6 ;) (type $3) (param $0 i32) - (local $1 i32) - (set_local $1 - (i32.load offset=24 - (i32.add - (i32.load - (i32.add - (i32.load - (i32.const 18100) - ) - (i32.const -12) - ) - ) - (i32.const 18100) - ) - ) - ) - (block $label$2 - (if - (get_local $0) - (br_if $label$2 - (call_indirect (type $1) - (get_local $1) - (i32.const 10888) - (get_local $0) - (i32.add - (i32.load offset=48 - (i32.load - (get_local $1) - ) - ) - (i32.const 8) - ) - ) - ) - ) - ) - ) - (func $__ZNSt3__213basic_ostreamIcNS_11char_traitsIcEEE3putEc (; 7 ;) (type $3) (param $0 i32) - (local $1 i32) - (local $2 i32) - (block $label$1 - (br_if $label$1 - (if (result i32) - (i32.load - (i32.add - (tee_local $2 - (tee_local $1 - (i32.load - (i32.add - (i32.load - (i32.add - (i32.load - (i32.const 18100) - ) - (i32.const -12) - ) - ) - (i32.const 18124) - ) - ) - ) - ) - (i32.const 24) - ) - ) - (i32.const 0) - (call_indirect (type $0) - (get_local $2) - (get_local $0) - (i32.add - (i32.load offset=52 - (i32.load - (get_local $1) - ) - ) - (i32.const 422) - ) - ) - ) - ) - ) - ) - (func $__ZNSt3__211__stdoutbufIcE8overflowEi (; 8 ;) (type $0) (param $0 i32) (param $1 i32) (result i32) - (i32.store8 - (i32.const 0) - (get_local $1) - ) - (drop - (call_indirect (type $1) - (i32.const 0) - (i32.const 0) - (i32.const 1) - (i32.add - (i32.load offset=36 - (i32.load - (i32.add - (get_local $0) - (i32.const 32) - ) - ) - ) - (i32.const 8) - ) - ) - ) - (i32.const 0) - ) - (func $__ZNSt3__211__stdoutbufIcE6xsputnEPKci (; 9 ;) (type $1) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (drop - (call_indirect (type $1) - (i32.const 0) - (get_local $1) - (get_local $2) - (i32.add - (i32.load offset=36 - (i32.load offset=32 - (get_local $0) - ) - ) - (i32.const 8) - ) - ) - ) - (i32.const 0) - ) -) -total - [funcs] : 9 - [memory-data] : 28 - [table-data] : 429 - [total] : 136 -1 - [vars] : 4 -1 + [total] : 136 + [vars] : 4 binary : 12 block : 9 break : 3 @@ -269,7 +18,7 @@ total load : 16 loop : 1 set_global : 1 - set_local : 6 -1 + set_local : 6 store : 5 (module (type $0 (func (param i32 i32) (result i32))) |