summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/SIMD/unary.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/SIMD/unary.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/SIMD/unary.js')
-rw-r--r--js/src/jit-test/tests/SIMD/unary.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/SIMD/unary.js b/js/src/jit-test/tests/SIMD/unary.js
new file mode 100644
index 000000000..34ec3fb10
--- /dev/null
+++ b/js/src/jit-test/tests/SIMD/unary.js
@@ -0,0 +1,35 @@
+load(libdir + 'simd.js');
+
+setJitCompilerOption("ion.warmup.trigger", 50);
+
+var notf = (function() {
+ var i32 = new Int32Array(1);
+ var f32 = new Float32Array(i32.buffer);
+ return function(x) {
+ f32[0] = x;
+ i32[0] = ~i32[0];
+ return f32[0];
+ }
+})();
+
+function f() {
+ var f4 = SIMD.Float32x4(1, 2, 3, 4);
+ var i4 = SIMD.Int32x4(1, 2, 3, 4);
+ var b4 = SIMD.Bool32x4(true, false, true, false);
+ var BitOrZero = (x) => x | 0;
+ for (var i = 0; i < 150; i++) {
+ assertEqX4(SIMD.Float32x4.neg(f4), unaryX4((x) => -x, f4, Math.fround));
+ assertEqX4(SIMD.Float32x4.abs(f4), unaryX4(Math.abs, f4, Math.fround));
+ assertEqX4(SIMD.Float32x4.sqrt(f4), unaryX4(Math.sqrt, f4, Math.fround));
+
+ assertEqX4(SIMD.Float32x4.reciprocalApproximation(f4), unaryX4((x) => 1 / x, f4, Math.fround), assertNear);
+ assertEqX4(SIMD.Float32x4.reciprocalSqrtApproximation(f4), unaryX4((x) => 1 / Math.sqrt(x), f4, Math.fround), assertNear);
+
+ assertEqX4(SIMD.Int32x4.not(i4), unaryX4((x) => ~x, i4, BitOrZero));
+ assertEqX4(SIMD.Int32x4.neg(i4), unaryX4((x) => -x, i4, BitOrZero));
+
+ assertEqX4(SIMD.Bool32x4.not(b4), unaryX4((x) => !x, b4, (x) => x ));
+ }
+}
+
+f();