diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-09-12 15:09:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 15:09:21 -0700 |
commit | c6729400f68a346c1d51702946bf6026638782a6 (patch) | |
tree | a564073fbc079a88df43e12f177c8f2753670bfa /test/wasm-only.fromasm.clamp | |
parent | 40f52f2ca41822e9dc47ff57239cdf299f7e1ce5 (diff) | |
download | binaryen-c6729400f68a346c1d51702946bf6026638782a6.tar.gz binaryen-c6729400f68a346c1d51702946bf6026638782a6.tar.bz2 binaryen-c6729400f68a346c1d51702946bf6026638782a6.zip |
precompute-propagate pass (#1179)
Implements #1172: this adds a variant of precompute, "precompute-propagate", which also does constant propagation. Precompute by itself just runs the interpreter on each expression and sees if it is in fact a constant; precompute-propagate also looks at the graph of connections between get and set locals, and propagates those constant values.
This helps with cases as noticed in #1168 - while in most cases LLVM will do this already, it's important when inlining, e.g. inlining of the clamping math functions. This new pass is run when inlining, and otherwise only in -O3/-Oz, as it does increase compilation time noticeably if run on everything (and for almost no benefit if LLVM has run).
Most of the code here is just refactoring out from the ssa pass the get/set graph computation, so it can now be used by both the ssa pass and precompute-propagate.
Diffstat (limited to 'test/wasm-only.fromasm.clamp')
-rw-r--r-- | test/wasm-only.fromasm.clamp | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/test/wasm-only.fromasm.clamp b/test/wasm-only.fromasm.clamp index 8f9825dda..2ac96b8ae 100644 --- a/test/wasm-only.fromasm.clamp +++ b/test/wasm-only.fromasm.clamp @@ -294,67 +294,41 @@ ) (func $test64 (local $0 i64) - (local $1 i64) - (local $2 i64) - (local $3 f32) - (local $4 f64) - (set_local $2 + (local $1 f32) + (local $2 f64) + (set_local $0 (call $i64s-div (block (result i64) - (set_local $2 + (set_local $0 (i64.mul (i64.sub (i64.add - (tee_local $0 - (i64.const 128849018897) - ) + (i64.const 128849018897) (i64.const 100) ) - (get_local $0) + (i64.const 128849018897) ) - (get_local $0) + (i64.const 128849018897) ) ) - (if (result i64) - (i64.eqz - (tee_local $1 - (get_local $0) - ) - ) - (i64.const 0) - (i64.div_u - (get_local $2) - (get_local $1) - ) + (i64.div_u + (get_local $0) + (i64.const 128849018897) ) ) - (get_local $0) + (i64.const 128849018897) ) ) - (set_local $1 - (if (result i64) - (i64.eqz - (tee_local $1 - (get_local $0) - ) - ) - (i64.const 0) - (i64.rem_u - (get_local $2) - (get_local $1) - ) + (set_local $0 + (i64.rem_u + (get_local $0) + (i64.const 128849018897) ) ) (drop - (if (result i64) - (i64.eqz - (get_local $0) - ) - (i64.const 0) - (i64.rem_s - (get_local $1) - (get_local $0) - ) + (i64.rem_s + (get_local $0) + (i64.const 128849018897) ) ) (drop @@ -404,7 +378,7 @@ (drop (call $f64-to-int64 (f64.promote/f32 - (tee_local $3 + (tee_local $1 (f32.convert_u/i64 (tee_local $0 (i64.extend_u/i32 @@ -420,7 +394,7 @@ ) (drop (call $f64-to-int64 - (tee_local $4 + (tee_local $2 (f64.convert_u/i64 (get_local $0) ) @@ -430,13 +404,13 @@ (drop (call $f64-to-int64 (f64.promote/f32 - (get_local $3) + (get_local $1) ) ) ) (drop (call $f64-to-int64 - (get_local $4) + (get_local $2) ) ) ) |