summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/SIMD/complex-4.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/complex-4.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/complex-4.js')
-rw-r--r--js/src/jit-test/tests/SIMD/complex-4.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/SIMD/complex-4.js b/js/src/jit-test/tests/SIMD/complex-4.js
new file mode 100644
index 000000000..ca5e8b0f6
--- /dev/null
+++ b/js/src/jit-test/tests/SIMD/complex-4.js
@@ -0,0 +1,70 @@
+load(libdir + 'simd.js');
+
+if (typeof SIMD === "undefined")
+ quit();
+
+setJitCompilerOption("baseline.warmup.trigger", 10);
+setJitCompilerOption("ion.warmup.trigger", 90);
+var max = 100; // Make have the warm-up counter high enough to
+ // consider inlining functions.
+
+var f4 = SIMD.Int32x4; // :TODO: Support Float32x4 arith.
+var f4add = f4.add;
+var f4sub = f4.sub;
+var f4mul = f4.mul;
+
+function c4mul(z1, z2) {
+ var { re: re1, im: im1 } = z1;
+ var { re: re2, im: im2 } = z2;
+ var rere = f4mul(re1, re2);
+ var reim = f4mul(re1, im2);
+ var imre = f4mul(im1, re2);
+ var imim = f4mul(im1, im2);
+ return { re: f4sub(rere, imim), im: f4add(reim, imre) };
+}
+
+function c4inv(z) {
+ var { re: re, im: im } = z;
+ var minus = f4(-1, -1, -1, -1);
+ return { re: re, im: f4mul(im, minus) };
+}
+
+function c4inv_inplace(z) {
+ var res = c4inv(z);
+ z.re = res.re;
+ z.im = res.im;
+}
+
+function c4norm(z) {
+ var { re: re, im: im } = c4mul(z, c4inv(z));
+ return re;
+}
+
+function c4scale(z, s) {
+ var { re: re, im: im } = z;
+ var f4s = f4(s, s, s, s);
+ return { re: f4mul(re, f4s), im: f4mul(im, f4s) };
+}
+
+var rotate90 = { re: f4(0, 0, 0, 0), im: f4(1, 1, 1, 1) };
+var cardinals = { re: f4(1, 0, -1, 0), im: f4(0, 1, 0, -1) };
+
+function test(dots) {
+ for (var j = 0; j < 4; j++) {
+ dots = c4mul(rotate90, dots);
+ if (j % 2 == 0) // Magic !
+ c4inv_inplace(dots);
+ dots = c4scale(dots, 2);
+ }
+ return dots;
+}
+
+assertEqX4(c4norm(cardinals), simdToArray(f4.splat(1)));
+var cardinals16 = c4scale(cardinals, 16);
+
+for (var i = 0; i < max; i++) {
+ var res = test(cardinals);
+ assertEqX4(c4norm(res), simdToArray(f4.splat(16 * 16)));
+ assertEqX4(res.re, simdToArray(cardinals16.re));
+ assertEqX4(res.im, simdToArray(cardinals16.im));
+}