summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2018-12-19 19:22:09 -0800
committerGitHub <noreply@github.com>2018-12-19 19:22:09 -0800
commit0f41b0708384c1f5d85304d5ed94d9edd57d38c9 (patch)
treeb79bc880af6e8534125fa9fb75a89932af4cd7d1
parentfcbcf3bd670a9ee793a836be49d825b944baf501 (diff)
downloadbinaryen-0f41b0708384c1f5d85304d5ed94d9edd57d38c9.tar.gz
binaryen-0f41b0708384c1f5d85304d5ed94d9edd57d38c9.tar.bz2
binaryen-0f41b0708384c1f5d85304d5ed94d9edd57d38c9.zip
Do not precompute v128 expressions (#1839)
Without this change, sequences like `i32.const 0, i32x4.splat` will get precomputed to v128.const ops, which are much larger and also not implemented in V8 yet. Until we have SIMD-aware optimization passes or at least engine support for v128.const, do not perform such transformations.
-rw-r--r--src/passes/Precompute.cpp4
-rw-r--r--test/passes/precompute.txt6
-rw-r--r--test/passes/precompute.wast5
3 files changed, 15 insertions, 0 deletions
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp
index 9fb7ab31c..042a8be20 100644
--- a/src/passes/Precompute.cpp
+++ b/src/passes/Precompute.cpp
@@ -161,6 +161,10 @@ struct Precompute : public WalkerPass<PostWalker<Precompute, UnifiedExpressionVi
void visitExpression(Expression* curr) {
// TODO: if get_local, only replace with a constant if we don't care about size...?
if (curr->is<Const>() || curr->is<Nop>()) return;
+ // Until engines implement v128.const and we have SIMD-aware optimizations
+ // that can break large v128.const instructions into smaller consts and
+ // splats, do not try to precompute v128 expressions.
+ if (curr->type == v128) return;
// try to evaluate this into a const
Flow flow = precomputeExpression(curr);
if (flow.breaking()) {
diff --git a/test/passes/precompute.txt b/test/passes/precompute.txt
index 1c060fbef..b199da603 100644
--- a/test/passes/precompute.txt
+++ b/test/passes/precompute.txt
@@ -3,6 +3,7 @@
(type $1 (func (result i32)))
(type $2 (func))
(type $3 (func (result f64)))
+ (type $4 (func (result v128)))
(memory $0 0)
(global $global i32 (i32.const 1))
(global $global-mut (mut i32) (i32.const 2))
@@ -211,4 +212,9 @@
(i32.const 2)
)
)
+ (func $no-simd-precompute (; 11 ;) (type $4) (result v128)
+ (i32x4.splat
+ (i32.const 0)
+ )
+ )
)
diff --git a/test/passes/precompute.wast b/test/passes/precompute.wast
index 2c87d3706..54c8cf6d2 100644
--- a/test/passes/precompute.wast
+++ b/test/passes/precompute.wast
@@ -306,4 +306,9 @@
)
)
)
+ (func $no-simd-precompute (result v128)
+ (i32x4.splat
+ (i32.const 0)
+ )
+ )
)