Skip to content

Commit 2a787cd

Browse files
authored
Do not precompute SIMDLoad (#2409)
This fixes a crash when programs containing load_splats are optimized.
1 parent 74d438e commit 2a787cd

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Use this handy checklist to make sure your new instructions are fully supported:
1717
- [ ] Validation added to src/wasm/wasm-validator.cpp
1818
- [ ] Interpretation added to src/wasm-interpreter.h
1919
- [ ] Effects handled in src/ir/effects.h
20+
- [ ] Precomputing handled in src/passes/Precompute.cpp
2021
- [ ] Hashing and comparing in src/ir/ExpressionAnalyzer.cpp
2122
- [ ] Parsing added in scripts/gen-s-parser.py and src/wasm/wasm-s-parser.cpp
2223
- [ ] Printing added in src/passes/Print.cpp

src/passes/Precompute.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ class PrecomputingExpressionRunner
125125
Flow visitAtomicNotify(AtomicNotify* curr) {
126126
return Flow(NOTPRECOMPUTABLE_FLOW);
127127
}
128+
Flow visitSIMDLoad(SIMDLoad* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); }
128129
Flow visitMemoryInit(MemoryInit* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); }
129130
Flow visitDataDrop(DataDrop* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); }
130131
Flow visitMemoryCopy(MemoryCopy* curr) { return Flow(NOTPRECOMPUTABLE_FLOW); }

test/passes/precompute-propagate.txt renamed to test/passes/precompute-propagate_all-features.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
(type $FUNCSIG$ii (func (param i32) (result i32)))
44
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
55
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
6+
(type $FUNCSIG$V (func (result v128)))
67
(memory $0 10 10)
78
(func $basic (; 0 ;) (type $FUNCSIG$vi) (param $p i32)
89
(local $x i32)
@@ -254,4 +255,13 @@
254255
(i32.const 14)
255256
)
256257
)
258+
(func $simd-load (; 17 ;) (type $FUNCSIG$V) (result v128)
259+
(local $x v128)
260+
(local.set $x
261+
(v8x16.load_splat
262+
(i32.const 0)
263+
)
264+
)
265+
(local.get $x)
266+
)
257267
)

test/passes/precompute-propagate.wast renamed to test/passes/precompute-propagate_all-features.wast

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,9 @@
170170
)
171171
)
172172
)
173+
(func $simd-load (result v128)
174+
(local $x v128)
175+
(local.set $x (v8x16.load_splat (i32.const 0)))
176+
(local.get $x)
177+
)
173178
)
174-

0 commit comments

Comments
 (0)