diff options
author | Alon Zakai <azakai@google.com> | 2023-04-05 12:53:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 19:53:50 +0000 |
commit | 04d451f3aadaf4d364e001fa9a849ef57a100a9e (patch) | |
tree | 3f82300c68a64df93b455ce19a9969d2d3c5dbe6 | |
parent | d21b6d04ff8020d76636ee0e09a8ccede9c0bf39 (diff) | |
download | binaryen-04d451f3aadaf4d364e001fa9a849ef57a100a9e.tar.gz binaryen-04d451f3aadaf4d364e001fa9a849ef57a100a9e.tar.bz2 binaryen-04d451f3aadaf4d364e001fa9a849ef57a100a9e.zip |
RemoveUnusedModuleElements: Add SIMD support for memory operations (#5632)
Fixes #5629
-rw-r--r-- | src/passes/RemoveUnusedModuleElements.cpp | 6 | ||||
-rw-r--r-- | test/lit/passes/remove-unused-module-elements_all-features.wast | 39 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/passes/RemoveUnusedModuleElements.cpp b/src/passes/RemoveUnusedModuleElements.cpp index 747b8806c..943448cfa 100644 --- a/src/passes/RemoveUnusedModuleElements.cpp +++ b/src/passes/RemoveUnusedModuleElements.cpp @@ -154,6 +154,12 @@ struct ReferenceFinder : public PostWalker<ReferenceFinder> { void visitAtomicNotify(AtomicNotify* curr) { note({ModuleElementKind::Memory, curr->memory}); } + void visitSIMDLoad(SIMDLoad* curr) { + note({ModuleElementKind::Memory, curr->memory}); + } + void visitSIMDLoadStoreLane(SIMDLoadStoreLane* curr) { + note({ModuleElementKind::Memory, curr->memory}); + } void visitMemoryInit(MemoryInit* curr) { note({ModuleElementKind::DataSegment, curr->segment}); note({ModuleElementKind::Memory, curr->memory}); diff --git a/test/lit/passes/remove-unused-module-elements_all-features.wast b/test/lit/passes/remove-unused-module-elements_all-features.wast index d5c394e30..c8b4a57df 100644 --- a/test/lit/passes/remove-unused-module-elements_all-features.wast +++ b/test/lit/passes/remove-unused-module-elements_all-features.wast @@ -722,3 +722,42 @@ ) ) ) +;; SIMD operations can keep memories alive +(module + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (memory $A 1 1) + (memory $A 1 1) + ;; CHECK: (memory $B 1 1) + (memory $B 1 1) + (memory $C-unused 1 1) + + (func "func" + (drop + (v128.load64_splat $A + (i32.const 0) + ) + ) + (drop + (v128.load16_lane $B 0 + (i32.const 0) + (v128.const i32x4 0 0 0 0) + ) + ) + ) +) +;; CHECK: (export "func" (func $0)) + +;; CHECK: (func $0 (type $none_=>_none) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (v128.load64_splat $A +;; CHECK-NEXT: (i32.const 0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (drop +;; CHECK-NEXT: (v128.load16_lane $B 0 +;; CHECK-NEXT: (i32.const 0) +;; CHECK-NEXT: (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) |