summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js')
-rw-r--r--js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js111
1 files changed, 111 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js b/js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js
new file mode 100644
index 0000000000..da1fb68e6b
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/simd/baseline-bug1636235.js
@@ -0,0 +1,111 @@
+// |jit-test| skip-if: !wasmSimdEnabled()
+
+// Bug 1636235: assorted corner case baseline SIMD bugs.
+
+function get(arr, loc, len) {
+ let res = [];
+ for ( let i=0; i < len; i++ ) {
+ res.push(arr[loc+i]);
+ }
+ return res;
+}
+
+// Pass v128 along a control flow edge in br_table
+
+var ins = wasmEvalText(`
+ (module
+ (memory (export "mem") 1 1)
+ (func (export "run") (param $k i32)
+ (v128.store (i32.const 0) (call $f (local.get $k))))
+ (func $f (param $k i32) (result v128)
+ (block $B2 (result v128)
+ (block $B1 (result v128)
+ (v128.const i32x4 1 2 3 4)
+ (br_table $B1 $B2 (local.get $k)))
+ (drop)
+ (v128.const i32x4 5 6 7 8))))`);
+
+var mem = new Int32Array(ins.exports.mem.buffer);
+ins.exports.run(0);
+assertDeepEq(get(mem, 0, 4), [5, 6, 7, 8]);
+
+ins.exports.run(1);
+assertDeepEq(get(mem, 0, 4), [1, 2, 3, 4]);
+
+// Materialize a ConstV128 off the value stack in popStackResults (also: check
+// that br passing v128 values works as it should).
+
+var ins = wasmEvalText(`
+ (module
+ (memory (export "mem") 1 1)
+
+ (func (export "run") (param $k i32)
+ (local $t0 v128) (local $t1 v128) (local $t2 v128)
+ (call $f (local.get $k))
+ (local.set $t2)
+ (local.set $t1)
+ (local.set $t0)
+ (v128.store (i32.const 32) (local.get $t2))
+ (v128.store (i32.const 16) (local.get $t1))
+ (v128.store (i32.const 0) (local.get $t0)))
+
+ (func $f (param $k i32) (result v128 v128 v128)
+ (block $B2 (result v128 v128 v128)
+ (if (local.get $k)
+ (br $B2 (v128.const i32x4 5 6 7 8)
+ (v128.const i32x4 9 10 11 12)
+ (v128.const i32x4 13 14 15 16))
+ (br $B2 (v128.const i32x4 -5 -6 -7 -8)
+ (v128.const i32x4 -9 -10 -11 -12)
+ (v128.const i32x4 -13 -14 -15 -16)))
+ (unreachable))))`);
+
+var mem = new Int32Array(ins.exports.mem.buffer);
+ins.exports.run(0);
+assertDeepEq(get(mem, 0, 4), [-5, -6, -7, -8]);
+assertDeepEq(get(mem, 4, 4), [-9, -10, -11, -12]);
+assertDeepEq(get(mem, 8, 4), [-13, -14, -15, -16]);
+
+ins.exports.run(1);
+assertDeepEq(get(mem, 0, 4), [5, 6, 7, 8]);
+assertDeepEq(get(mem, 4, 4), [9, 10, 11, 12]);
+assertDeepEq(get(mem, 8, 4), [13, 14, 15, 16]);
+
+// Check that br_if passing v128 values works as it should.
+
+var ins = wasmEvalText(`
+ (module
+ (memory (export "mem") 1 1)
+
+ (func (export "run") (param $k i32)
+ (local $t0 v128) (local $t1 v128) (local $t2 v128)
+ (call $f (local.get $k))
+ (local.set $t2)
+ (local.set $t1)
+ (local.set $t0)
+ (v128.store (i32.const 32) (local.get $t2))
+ (v128.store (i32.const 16) (local.get $t1))
+ (v128.store (i32.const 0) (local.get $t0)))
+
+ (func $f (param $k i32) (result v128 v128 v128)
+ (block $B2 (result v128 v128 v128)
+ (v128.const i32x4 5 6 7 8)
+ (v128.const i32x4 9 10 11 12)
+ (v128.const i32x4 13 14 15 16)
+ (br_if $B2 (local.get $k))
+ drop drop drop
+ (v128.const i32x4 -5 -6 -7 -8)
+ (v128.const i32x4 -9 -10 -11 -12)
+ (v128.const i32x4 -13 -14 -15 -16))))`);
+
+var mem = new Int32Array(ins.exports.mem.buffer);
+ins.exports.run(0);
+assertDeepEq(get(mem, 0, 4), [-5, -6, -7, -8]);
+assertDeepEq(get(mem, 4, 4), [-9, -10, -11, -12]);
+assertDeepEq(get(mem, 8, 4), [-13, -14, -15, -16]);
+
+ins.exports.run(1);
+assertDeepEq(get(mem, 0, 4), [5, 6, 7, 8]);
+assertDeepEq(get(mem, 4, 4), [9, 10, 11, 12]);
+assertDeepEq(get(mem, 8, 4), [13, 14, 15, 16]);
+