Skip to content

Commit

Permalink
don't precompute anything to a vector for now (WebAssembly#1999)
Browse files Browse the repository at this point in the history
We handled this for the normal case, but the optimizer can also precompute a return into a value, so check the output of the precomputation as well.
  • Loading branch information
kripken authored Apr 11, 2019
1 parent 7be5d23 commit 6b517f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/passes/Precompute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ struct Precompute : public WalkerPass<PostWalker<Precompute, UnifiedExpressionVi
// 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;
if (isVectorType(curr->type)) return;
// try to evaluate this into a const
Flow flow = precomputeExpression(curr);
if (isVectorType(flow.value.type)) return;
if (flow.breaking()) {
if (flow.breakTo == NOTPRECOMPUTABLE_FLOW) return;
if (flow.breakTo == RETURN_FLOW) {
Expand Down
7 changes: 7 additions & 0 deletions test/passes/precompute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,11 @@
(i32.const 0)
)
)
(func $no-simd-precompute-if (; 12 ;) (type $4) (result v128)
(return
(i32x4.splat
(i32.const 0)
)
)
)
)
7 changes: 7 additions & 0 deletions test/passes/precompute.wast
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,11 @@
(i32.const 0)
)
)
(func $no-simd-precompute-if (result v128)
(return
(i32x4.splat
(i32.const 0)
)
)
)
)

0 comments on commit 6b517f6

Please sign in to comment.