Bug 1072368: Merge SIMD.js comparison tests in comparisons.js; r=till
authorBenjamin Bouvier <benj@benj.me>
Mon, 24 Nov 2014 16:09:29 +0100
changeset 217156 66c241782eed86eb4cceff8d1826c032562a4812
parent 217155 953e14ecbc020ffd6f58aba18082f8a4dc585d34
child 217157 2471a54e5a5ae336d633841a1a23fe561610ab05
push id52230
push userbenj@benj.me
push dateMon, 24 Nov 2014 15:10:34 +0000
treeherdermozilla-inbound@2471a54e5a5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1072368
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1072368: Merge SIMD.js comparison tests in comparisons.js; r=till
js/src/tests/ecma_6/TypedObject/simd/comparisons.js
js/src/tests/ecma_6/TypedObject/simd/float32x4equal.js
js/src/tests/ecma_6/TypedObject/simd/float32x4greaterthan.js
js/src/tests/ecma_6/TypedObject/simd/float32x4greaterthanorequal.js
js/src/tests/ecma_6/TypedObject/simd/float32x4lessthan.js
js/src/tests/ecma_6/TypedObject/simd/float32x4lessthanorequal.js
js/src/tests/ecma_6/TypedObject/simd/float32x4notequal.js
js/src/tests/ecma_6/TypedObject/simd/int32x4equal.js
js/src/tests/ecma_6/TypedObject/simd/int32x4greaterthan.js
js/src/tests/ecma_6/TypedObject/simd/int32x4lessthan.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_6/TypedObject/simd/comparisons.js
@@ -0,0 +1,102 @@
+// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
+
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var float32x4 = SIMD.float32x4;
+var int32x4 = SIMD.int32x4;
+
+var fround = Math.fround;
+
+function boolToSimdLogical(b) {
+    return b ? 0xFFFFFFFF | 0 : 0x0;
+}
+
+function testEqualFloat32x4(v, w) {
+    testBinaryFunc(v, w, float32x4.equal, (x, y) => boolToSimdLogical(fround(x) == fround(y)));
+}
+function testNotEqualFloat32x4(v, w) {
+    testBinaryFunc(v, w, float32x4.notEqual, (x, y) => boolToSimdLogical(fround(x) != fround(y)));
+}
+function testLessThanFloat32x4(v, w) {
+    testBinaryFunc(v, w, float32x4.lessThan, (x, y) => boolToSimdLogical(fround(x) < fround(y)));
+}
+function testLessThanOrEqualFloat32x4(v, w) {
+    testBinaryFunc(v, w, float32x4.lessThanOrEqual, (x, y) => boolToSimdLogical(fround(x) <= fround(y)));
+}
+function testGreaterThanFloat32x4(v, w) {
+    testBinaryFunc(v, w, float32x4.greaterThan, (x, y) => boolToSimdLogical(fround(x) > fround(y)));
+}
+function testGreaterThanOrEqualFloat32x4(v, w) {
+    testBinaryFunc(v, w, float32x4.greaterThanOrEqual, (x, y) => boolToSimdLogical(fround(x) >= fround(y)));
+}
+
+function testEqualInt32x4(v, w) {
+    testBinaryFunc(v, w, int32x4.equal, (x, y) => boolToSimdLogical(x == y));
+}
+function testNotEqualInt32x4(v, w) {
+    testBinaryFunc(v, w, int32x4.notEqual, (x, y) => boolToSimdLogical(x != y));
+}
+function testLessThanInt32x4(v, w) {
+    testBinaryFunc(v, w, int32x4.lessThan, (x, y) => boolToSimdLogical(x < y));
+}
+function testLessThanOrEqualInt32x4(v, w) {
+    testBinaryFunc(v, w, int32x4.lessThanOrEqual, (x, y) => boolToSimdLogical(x <= y));
+}
+function testGreaterThanInt32x4(v, w) {
+    testBinaryFunc(v, w, int32x4.greaterThan, (x, y) => boolToSimdLogical(x > y));
+}
+function testGreaterThanOrEqualInt32x4(v, w) {
+    testBinaryFunc(v, w, int32x4.greaterThanOrEqual, (x, y) => boolToSimdLogical(x >= y));
+}
+
+function test() {
+  var float32x4val = [
+      float32x4(1, 20, 30, 4),
+      float32x4(10, 2, 3, 40),
+      float32x4(9.999, 2.1234, 30.4443, 4),
+      float32x4(10, 2.1233, 30.4444, 4.0001),
+      float32x4(NaN, -Infinity, +Infinity, -0),
+      float32x4(+Infinity, NaN, -0, -Infinity),
+      float32x4(13.37, 42.42, NaN, 0)
+  ];
+
+  var v, w;
+  for (v of float32x4val) {
+      for (w of float32x4val) {
+          testEqualFloat32x4(v, w);
+          testNotEqualFloat32x4(v, w);
+          testLessThanFloat32x4(v, w);
+          testLessThanOrEqualFloat32x4(v, w);
+          testGreaterThanFloat32x4(v, w);
+          testGreaterThanOrEqualFloat32x4(v, w);
+      }
+  }
+
+  var int32x4val = [
+      int32x4(1, 2, 3, 4),
+      int32x4(-1, -2, -3, -4),
+      int32x4(-1, 2, -3, 4),
+      int32x4(1, -2, 3, -4),
+      int32x4(INT32_MAX, INT32_MAX, INT32_MIN, INT32_MIN),
+      int32x4(INT32_MAX, INT32_MIN, INT32_MAX, INT32_MIN)
+  ];
+
+  for (v of int32x4val) {
+      for (w of int32x4val) {
+          testEqualInt32x4(v, w);
+          testNotEqualInt32x4(v, w);
+          testLessThanInt32x4(v, w);
+          testLessThanOrEqualInt32x4(v, w);
+          testGreaterThanInt32x4(v, w);
+          testGreaterThanOrEqualInt32x4(v, w);
+      }
+  }
+
+  if (typeof reportCompare === "function")
+    reportCompare(true, true);
+}
+
+test();
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/float32x4equal.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 946042;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'float32x4 equal';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  // FIXME -- Bug 1081697: Amend to check for correctness of NaN/-0/Infinity/-Infinity border cases.
-
-  var a = float32x4(1, 20, 30, 40);
-  var b = float32x4(10, 20, 30, 4);
-  var c = SIMD.float32x4.equal(a, b);
-  assertEq(c.x, 0);
-  assertEq(c.y, -1);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  var d = float32x4(1.89, 20.51, 30.46, 40.12);
-  var e = float32x4(10.89, 20.51, Math.fround(30.46), 4.12);
-  var f = SIMD.float32x4.equal(d, e);
-  assertEq(c.x, 0);
-  assertEq(c.y, -1);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/float32x4greaterthan.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 946042;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'float32x4 greaterThan';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  // FIXME -- Bug 1081697: Amend to check for correctness of -0/Infinity/-Infinity border cases.
-  // FIXME -- Bug 1068028: Amend to check for correctness of NaN border cases once the semantics are defined.
-
-  var a = float32x4(1, 20, 3, 40);
-  var b = float32x4(10, 2, 30, 4);
-  var c = SIMD.float32x4.greaterThan(b, a);
-  assertEq(c.x, -1);
-  assertEq(c.y, 0);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  var d = float32x4(10.8399, 20.37, 3.07, 4.6802);
-  var e = float32x4(10.8401, 20.367, 3.1, 4.6801);
-  var f = float32x4.greaterThan(e, d);
-  assertEq(f.x, -1);
-  assertEq(f.y, 0);
-  assertEq(f.z, -1);
-  assertEq(f.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/float32x4greaterthanorequal.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 946042;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'float32x4 greaterThanOrEqual';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  // FIXME -- Bug 1081697: Amend to check for correctness of -0/Infinity/-Infinity border cases.
-  // FIXME -- Bug 1068028: Amend to check for correctness of NaN border cases once the semantics are defined.
-
-  var a = float32x4(1, 20, 30, 40);
-  var b = float32x4(10, 20, 30, 4);
-  var c = SIMD.float32x4.greaterThanOrEqual(b, a);
-  assertEq(c.x, -1);
-  assertEq(c.y, -1);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  var d = float32x4(10.029, 20.87, 30.56, 4.7);
-  var e = float32x4(10.03, 20.87, 30.56, 4.698);
-  var f = float32x4.greaterThanOrEqual(e, d);
-  assertEq(f.x, -1);
-  assertEq(f.y, -1);
-  assertEq(f.z, -1);
-  assertEq(f.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/float32x4lessthan.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 946042;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'float32x4 lessThan';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  // FIXME -- Bug 1081697: Amend to check for correctness of -0/Infinity/-Infinity border cases.
-  // FIXME -- Bug 1068028: Amend to check for correctness of NaN border cases once the semantics are defined.
-
-  var a = float32x4(1, 20, 3, 40);
-  var b = float32x4(10, 2, 30, 4);
-  var c = SIMD.float32x4.lessThan(a, b);
-  assertEq(c.x, -1);
-  assertEq(c.y, 0);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  var d = float32x4(1.5399, 20.001, 30.045, 4.74);
-  var e = float32x4(1.54, 19.999, 30.05, 4.72);
-  var f = float32x4.lessThan(a, b);
-  assertEq(f.x, -1);
-  assertEq(f.y, 0);
-  assertEq(f.z, -1);
-  assertEq(f.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/float32x4lessthanorequal.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 946042;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'float32x4 lessThanOrEqual';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  // FIXME -- Bug 1081697: Amend to check for correctness of -0/Infinity/-Infinity border cases.
-  // FIXME -- Bug 1068028: Amend to check for correctness of NaN border cases once the semantics are defined.
-
-  var a = float32x4(1, 20, 30, 40);
-  var b = float32x4(10, 20, 30, 4);
-  var c = SIMD.float32x4.lessThanOrEqual(a, b);
-  assertEq(c.x, -1);
-  assertEq(c.y, -1);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  var d = float32x4(9.999, 20.78, 30.14, 40.1235);
-  var e = float32x4(10, 20.78, 30.14, 40.123);
-  var f = float32x4.lessThanOrEqual(d, e);
-  assertEq(f.x, -1);
-  assertEq(f.y, -1);
-  assertEq(f.z, -1);
-  assertEq(f.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/float32x4notequal.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 946042;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'float32x4 notEqual';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  // FIXME -- Bug 1081697: Amend to check for correctness of NaN/-0/Infinity/-Infinity border cases.
-
-  var a = float32x4(1, 20, 30, 40);
-  var b = float32x4(10, 20, 30, 4);
-  var c = SIMD.float32x4.notEqual(a, b);
-  assertEq(c.x, -1);
-  assertEq(c.y, 0);
-  assertEq(c.z, 0);
-  assertEq(c.w, -1);
-
-  var d = float32x4(9.98, 20.65, 30.14, 4.235);
-  var e = float32x4(9.99, 20.65, Math.fround(30.14), 4.23);
-  var f = SIMD.float32x4.notEqual(d, e);
-  assertEq(f.x, -1);
-  assertEq(f.y, 0);
-  assertEq(f.z, 0);
-  assertEq(f.w, -1);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/int32x4equal.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 996076;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'int32x4 equal';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  var a = int32x4(1, 20, 30, 40);
-  var b = int32x4(10, 20, 30, 4);
-  var c = SIMD.int32x4.equal(a, b);
-  assertEq(c.x, 0);
-  assertEq(c.y, -1);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/int32x4greaterthan.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 996076;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'int32x4 greaterThan';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  var a = int32x4(1, 20, 3, 40);
-  var b = int32x4(10, 2, 30, 4);
-  var c = SIMD.int32x4.greaterThan(b,a);
-  assertEq(c.x, -1);
-  assertEq(c.y, 0);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_6/TypedObject/simd/int32x4lessthan.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 996076;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'int32x4 lessThan';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  var a = int32x4(1, 20, 3, 40);
-  var b = int32x4(10, 2, 30, 4);
-  var c = SIMD.int32x4.lessThan(a, b);
-  assertEq(c.x, -1);
-  assertEq(c.y, 0);
-  assertEq(c.z, -1);
-  assertEq(c.w, 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-