diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-06-05 19:34:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-05 19:34:34 -0700 |
commit | 616abe47020c90278eaf8d14ae9815c31d2d14fb (patch) | |
tree | 91ad94c219f2028285605e3285b19d81ad655878 | |
parent | 917fabf8fb8c2efbfadc608efa79c0937830ce10 (diff) | |
download | binaryen-616abe47020c90278eaf8d14ae9815c31d2d14fb.tar.gz binaryen-616abe47020c90278eaf8d14ae9815c31d2d14fb.tar.bz2 binaryen-616abe47020c90278eaf8d14ae9815c31d2d14fb.zip |
Use splatted zero vector in makeZero (#2164)
This prevents the optimizer from producing v128.const instructions,
which are not supported by V8 at this time.
-rw-r--r-- | src/ir/literal-utils.h | 8 | ||||
-rw-r--r-- | test/passes/ssa-nomerge_enable-simd.txt (renamed from test/passes/ssa-nomerge.txt) | 12 | ||||
-rw-r--r-- | test/passes/ssa-nomerge_enable-simd.wast (renamed from test/passes/ssa-nomerge.wast) | 10 |
3 files changed, 29 insertions, 1 deletions
diff --git a/src/ir/literal-utils.h b/src/ir/literal-utils.h index 543c34e9f..63a2b3b44 100644 --- a/src/ir/literal-utils.h +++ b/src/ir/literal-utils.h @@ -17,6 +17,7 @@ #ifndef wasm_ir_literal_utils_h #define wasm_ir_literal_utils_h +#include "wasm-builder.h" #include "wasm.h" namespace wasm { @@ -31,6 +32,13 @@ inline Expression* makeFromInt32(int32_t x, Type type, Module& wasm) { } inline Expression* makeZero(Type type, Module& wasm) { + // TODO: Switch to using v128.const once V8 supports it + // (https://bugs.chromium.org/p/v8/issues/detail?id=8460) + if (type == v128) { + Builder builder(wasm); + return builder.makeUnary(SplatVecI32x4, + builder.makeConst(Literal(int32_t(0)))); + } return makeFromInt32(0, type, wasm); } diff --git a/test/passes/ssa-nomerge.txt b/test/passes/ssa-nomerge_enable-simd.txt index 48f34f054..7674e0626 100644 --- a/test/passes/ssa-nomerge.txt +++ b/test/passes/ssa-nomerge_enable-simd.txt @@ -1,6 +1,8 @@ (module (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vii (func (param i32 i32))) + (type $FUNCSIG$v (func)) + (memory $0 1 1) (global $global$0 (mut i32) (i32.const 1)) (func $basics (; 0 ;) (type $FUNCSIG$vi) (param $x i32) (local $y i32) @@ -199,4 +201,14 @@ (local.get $x) ) ) + (func $simd-zero (; 4 ;) (type $FUNCSIG$v) + (local $0 v128) + (v128.store align=4 + (i32.const 0) + (i32x4.splat + (i32.const 0) + ) + ) + (unreachable) + ) ) diff --git a/test/passes/ssa-nomerge.wast b/test/passes/ssa-nomerge_enable-simd.wast index dec7c89e5..fa1187a7f 100644 --- a/test/passes/ssa-nomerge.wast +++ b/test/passes/ssa-nomerge_enable-simd.wast @@ -1,4 +1,5 @@ (module + (memory 1 1) (global $global$0 (mut i32) (i32.const 1)) (func $basics (param $x i32) (local $y i32) @@ -98,5 +99,12 @@ ) (call $nomerge (local.get $x) (local.get $x)) ) + (func $simd-zero + (local $0 v128) + (v128.store align=4 + (i32.const 0) + (local.get $0) + ) + (unreachable) + ) ) - |