Bug 1108807: Group SIMD.js shift tests; r=till
authorBenjamin Bouvier <benj@benj.me>
Wed, 10 Dec 2014 13:26:00 +0100
changeset 219075 73f9d4bea389b2dcd01204f9f16ffc1342d3d7bb
parent 219074 04a59790e7f2ee48e5391976b7975d6cd390434f
child 219076 66151fa917a7df596fe1e45811d6d2937754e97c
push id27954
push userryanvm@gmail.com
push dateWed, 10 Dec 2014 21:10:24 +0000
treeherdermozilla-central@0cf461e62ce5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1108807
milestone37.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 1108807: Group SIMD.js shift tests; r=till
js/src/tests/ecma_7/SIMD/int32x4lsh.js
js/src/tests/ecma_7/SIMD/int32x4rsh.js
js/src/tests/ecma_7/SIMD/int32x4ursh.js
js/src/tests/ecma_7/SIMD/shell.js
js/src/tests/ecma_7/SIMD/shifts.js
deleted file mode 100644
--- a/js/src/tests/ecma_7/SIMD/int32x4lsh.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 996076;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'int32x4 lsh';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  for (var bits = 0; bits < 32; bits++) {
-      var a = int32x4(-1, 2, -3, 4);
-      var c = SIMD.int32x4.shiftLeftByScalar(a, bits);
-      assertEq(c.x, -1 << bits);
-      assertEq(c.y, 2 << bits);
-      assertEq(c.z, -3 << bits);
-      assertEq(c.w, 4 << bits);
-  }
-
-  var INT32_MAX = Math.pow(2, 31) - 1;
-  var INT32_MIN = -Math.pow(2, 31);
-
-  var d = int32x4(INT32_MAX, INT32_MIN, INT32_MAX, INT32_MIN);
-  var f = SIMD.int32x4.shiftLeftByScalar(d, 1);
-  assertEq(f.x, (INT32_MAX << 1) | 0);
-  assertEq(f.y, (INT32_MIN << 1) | 0);
-  assertEq(f.z, (INT32_MAX << 1) | 0);
-  assertEq(f.w, (INT32_MIN << 1) | 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_7/SIMD/int32x4rsh.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 996076;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'int32x4 rsh';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  for (var bits = 0; bits < 32; bits++) {
-      var a = int32x4(-1, 2, -3, 4);
-      var c = SIMD.int32x4.shiftRightArithmeticByScalar(a, bits);
-      assertEq(c.x, -1 >> bits);
-      assertEq(c.y, 2 >> bits);
-      assertEq(c.z, -3 >> bits);
-      assertEq(c.w, 4 >> bits);
-  }
-
-  var INT32_MAX = Math.pow(2, 31) - 1;
-  var INT32_MIN = -Math.pow(2, 31);
-  var d = int32x4(INT32_MAX, INT32_MIN, INT32_MAX, INT32_MIN);
-  var f = SIMD.int32x4.shiftRightArithmeticByScalar(d, 1);
-  assertEq(f.x, INT32_MAX >> 1);
-  assertEq(f.y, INT32_MIN >> 1);
-  assertEq(f.z, INT32_MAX >> 1);
-  assertEq(f.w, INT32_MIN >> 1);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
deleted file mode 100644
--- a/js/src/tests/ecma_7/SIMD/int32x4ursh.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
-var BUGNUMBER = 996076;
-var float32x4 = SIMD.float32x4;
-var int32x4 = SIMD.int32x4;
-
-var summary = 'int32x4 ursh';
-
-function test() {
-  print(BUGNUMBER + ": " + summary);
-
-  for (var bits = 0; bits < 32; bits++) {
-      var a = int32x4(-1, 2, -3, 4);
-      var c = SIMD.int32x4.shiftRightLogicalByScalar(a, bits);
-      assertEq(c.x >>> 0, -1 >>> bits);
-      assertEq(c.y >>> 0, 2 >>> bits);
-      assertEq(c.z >>> 0, -3 >>> bits);
-      assertEq(c.w >>> 0, 4 >>> bits);
-  }
-
-  var INT32_MAX = Math.pow(2, 31) - 1;
-  var INT32_MIN = -Math.pow(2, 31);
-
-  var d = int32x4(INT32_MAX, INT32_MIN, INT32_MAX, INT32_MIN);
-  var f = SIMD.int32x4.shiftRightLogicalByScalar(d, 0);
-  assertEq(f.x, (INT32_MAX >>> 0) | 0);
-  assertEq(f.y, (INT32_MIN >>> 0) | 0);
-  assertEq(f.z, (INT32_MAX >>> 0) | 0);
-  assertEq(f.w, (INT32_MIN >>> 0) | 0);
-
-  if (typeof reportCompare === "function")
-    reportCompare(true, true);
-}
-
-test();
-
--- a/js/src/tests/ecma_7/SIMD/shell.js
+++ b/js/src/tests/ecma_7/SIMD/shell.js
@@ -23,8 +23,18 @@ function testBinaryFunc(v, w, simdFunc, 
     var warr = simdToArray(w);
 
     var observed = simdToArray(simdFunc(v, w));
     var expected = varr.map(function(v, i) { return func(varr[i], warr[i]); });
 
     for (var i = 0; i < observed.length; i++)
         assertEq(observed[i], expected[i]);
 }
+
+function testBinaryScalarFunc(v, scalar, simdFunc, func) {
+    var varr = simdToArray(v);
+
+    var observed = simdToArray(simdFunc(v, scalar));
+    var expected = varr.map(function(v, i) { return func(varr[i], scalar); });
+
+    for (var i = 0; i < observed.length; i++)
+        assertEq(observed[i], expected[i]);
+}
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_7/SIMD/shifts.js
@@ -0,0 +1,37 @@
+// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
+
+/*
+ * Any copyright is dedicated to the Public Domain.
+ * https://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+var int32x4 = SIMD.int32x4;
+
+function lsh(a, b) {
+    return (a << b) | 0;
+}
+function rsh(a, b) {
+    return (a >> b) | 0;
+}
+function ursh(a, b) {
+    return (a >>> b) | 0;
+}
+
+function test() {
+  for (var v of [
+            int32x4(-1, 2, -3, 4),
+            int32x4(INT32_MAX, INT32_MIN, INT32_MAX - 1, INT32_MIN + 1)
+       ])
+  {
+      for (var bits = 0; bits < 32; bits++) {
+          testBinaryScalarFunc(v, bits, int32x4.shiftLeftByScalar, lsh);
+          testBinaryScalarFunc(v, bits, int32x4.shiftRightArithmeticByScalar, rsh);
+          testBinaryScalarFunc(v, bits, int32x4.shiftRightLogicalByScalar, ursh);
+      }
+  }
+
+  if (typeof reportCompare === "function")
+    reportCompare(true, true);
+}
+
+test();