diff options
-rw-r--r-- | src/passes/Precompute.cpp | 9 | ||||
-rw-r--r-- | test/lit/passes/Oz.wast | 15 | ||||
-rw-r--r-- | test/passes/precompute_all-features.txt | 15 | ||||
-rw-r--r-- | test/passes/precompute_all-features.wast | 9 |
4 files changed, 18 insertions, 30 deletions
diff --git a/src/passes/Precompute.cpp b/src/passes/Precompute.cpp index 621c2f886..f599990a0 100644 --- a/src/passes/Precompute.cpp +++ b/src/passes/Precompute.cpp @@ -271,17 +271,8 @@ struct Precompute if (Properties::isConstantExpression(curr) || 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.isVector()) { - return; - } // try to evaluate this into a const Flow flow = precomputeExpression(curr); - if (flow.getType().hasVector()) { - return; - } if (!canEmitConstantFor(flow.values)) { return; } diff --git a/test/lit/passes/Oz.wast b/test/lit/passes/Oz.wast index 82e0acea5..7dc8c7c5e 100644 --- a/test/lit/passes/Oz.wast +++ b/test/lit/passes/Oz.wast @@ -1,7 +1,7 @@ ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. ;; NOTE: This test was ported using port_test.py and could be cleaned up. -;; RUN: foreach %s %t wasm-opt -Oz -S -o - | filecheck %s +;; RUN: foreach %s %t wasm-opt -Oz --all-features -S -o - | filecheck %s (module (memory 100 100) @@ -11,6 +11,8 @@ ;; CHECK: (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) + ;; CHECK: (type $none_=>_v128 (func (result v128))) + ;; CHECK: (memory $0 100 100) ;; CHECK: (export "localcse" (func $basics)) @@ -33,6 +35,8 @@ ;; CHECK: (export "eliminate-redundant-checks-skip-2" (func $14)) + ;; CHECK: (export "precompute-simd" (func $precompute-simd)) + ;; CHECK: (func $basics (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) ;; CHECK-NEXT: (i32.add ;; CHECK-NEXT: (local.tee $0 @@ -270,4 +274,13 @@ ) (i32.const 0) ) + + ;; CHECK: (func $precompute-simd (; has Stack IR ;) (result v128) + ;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) + ;; CHECK-NEXT: ) + (func $precompute-simd (export "precompute-simd") (result v128) + (i32x4.splat + (i32.const 0) + ) + ) ) diff --git a/test/passes/precompute_all-features.txt b/test/passes/precompute_all-features.txt index b707f4248..89d334a93 100644 --- a/test/passes/precompute_all-features.txt +++ b/test/passes/precompute_all-features.txt @@ -2,8 +2,8 @@ (type $none_=>_none (func)) (type $none_=>_i32 (func (result i32))) (type $none_=>_f64 (func (result f64))) - (type $none_=>_v128 (func (result v128))) (type $0 (func (param i32))) + (type $none_=>_v128 (func (result v128))) (type $none_=>_i32_i64 (func (result i32 i64))) (type $none_=>_externref (func (result externref))) (global $global i32 (i32.const 1)) @@ -217,17 +217,8 @@ (i32.const 2) ) ) - (func $no-simd-precompute (result v128) - (i32x4.splat - (i32.const 0) - ) - ) - (func $no-simd-precompute-if (result v128) - (return - (i32x4.splat - (i32.const 0) - ) - ) + (func $simd-precompute (result v128) + (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) ) (func $no-memory-init-precompute (memory.init 0 diff --git a/test/passes/precompute_all-features.wast b/test/passes/precompute_all-features.wast index 1275524e0..9fb444cb5 100644 --- a/test/passes/precompute_all-features.wast +++ b/test/passes/precompute_all-features.wast @@ -324,18 +324,11 @@ ) ) ) - (func $no-simd-precompute (result v128) + (func $simd-precompute (result v128) (i32x4.splat (i32.const 0) ) ) - (func $no-simd-precompute-if (result v128) - (return - (i32x4.splat - (i32.const 0) - ) - ) - ) (func $no-memory-init-precompute (memory.init 0 (i32.const 512) |