Bug 1657628 - Fix bugs in some ad-hack simd tests. r=jseward
☠☠ backed out by 2ce43b1fe3db ☠ ☠
authorLars T Hansen <lhansen@mozilla.com>
Wed, 12 Aug 2020 07:50:07 +0000
changeset 544376 a6d240ef908b37bf509c46676bd70831174d2102
parent 544375 2e7ddb00c8f9240e148cf5843b50a7ba7b913351
child 544377 64e82366834a3c20d571e082be358c042f2c8b2e
push id123998
push userlhansen@mozilla.com
push dateWed, 12 Aug 2020 08:21:24 +0000
treeherderautoland@c19dcb11b940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjseward
bugs1657628
milestone81.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 1657628 - Fix bugs in some ad-hack simd tests. r=jseward Two bugs: - an accidental redefinition of the 'eq' predicate resulted in the 'permute' function not working and thus in us not testing floating point operations for NaN, Infinity, and some other interesting values. - the previous bug masked the fact that the max and min operations for floating point were not implemented properly; they have to handle NaN specially. Differential Revision: https://phabricator.services.mozilla.com/D86315
js/src/jit-test/tests/wasm/simd/ad-hack.js
--- a/js/src/jit-test/tests/wasm/simd/ad-hack.js
+++ b/js/src/jit-test/tests/wasm/simd/ad-hack.js
@@ -69,25 +69,25 @@ function iota(len) {
 function cross(xs) {
     let results = [];
     for ( let x of xs )
         for ( let y of xs )
             results.push([x,y]);
     return results;
 }
 
-function eq(a, b) {
+function equal(a, b) {
     return a === b || isNaN(a) && isNaN(b);
 }
 
 // Remove a value v from an array xs, comparing equal for NaN.
 function remove(v, xs) {
     let result = [];
     for ( let w of xs ) {
-        if (eq(v, w))
+        if (equal(v, w))
             continue;
         result.push(w);
     }
     return result;
 }
 
 function permute(xs) {
     if (xs.length == 1)
@@ -503,21 +503,36 @@ function lt(truth) { return (x, y) => x 
 function gt(truth) { return (x, y) => x > y ? truth : 0 }
 function le(truth) { return (x, y) => x <= y ? truth : 0 }
 function ge(truth) { return (x, y) => x >= y ? truth : 0 }
 
 function fadd(x, y) { return Math.fround(x+y) }
 function fsub(x, y) { return Math.fround(x-y) }
 function fmul(x, y) { return Math.fround(x*y) }
 function fdiv(x, y) { return Math.fround(x/y) }
-
+function fmin(x, y) {
+    if (x == y) return x;
+    if (x < y) return x;
+    if (y < x) return y;
+    if (isNaN(x)) return x;
+    return y;
+}
+function fmax(x, y) {
+    if (x == y) return x;
+    if (x > y) return x;
+    if (y > x) return y;
+    if (isNaN(x)) return x;
+    return y;
+}
 function dadd(x, y) { return x+y }
 function dsub(x, y) { return x-y }
 function dmul(x, y) { return x*y }
 function ddiv(x, y) { return x/y }
+var dmax = fmax;
+var dmin = fmin;
 
 function op_sat_s(bits, op) {
     return (x, y) => {
         return signed_saturate(op(sign_extend(x, bits),
                                   sign_extend(y, bits)),
                                bits);
     }
 }
@@ -619,24 +634,24 @@ for ( let [op, memtype, rop, resultmemty
        ['v128.and', Uint8Array, and],
        ['v128.or', Uint8Array, or],
        ['v128.xor', Uint8Array, xor],
        ['v128.andnot', Uint8Array, andnot],
        ['f32x4.add', Float32Array, fadd],
        ['f32x4.sub', Float32Array, fsub],
        ['f32x4.mul', Float32Array, fmul],
        ['f32x4.div', Float32Array, fdiv],
-       ['f32x4.min', Float32Array, min],
-       ['f32x4.max', Float32Array, max],
+       ['f32x4.min', Float32Array, fmin],
+       ['f32x4.max', Float32Array, fmax],
        ['f64x2.add', Float64Array, dadd],
        ['f64x2.sub', Float64Array, dsub],
        ['f64x2.mul', Float64Array, dmul],
        ['f64x2.div', Float64Array, ddiv],
-       ['f64x2.min', Float64Array, min],
-       ['f64x2.max', Float64Array, max],
+       ['f64x2.min', Float64Array, dmin],
+       ['f64x2.max', Float64Array, dmax],
        ['i8x16.eq', Int8Array, eq(-1)],
        ['i8x16.ne', Int8Array, ne(-1)],
        ['i8x16.lt_s', Int8Array, lt(-1)],
        ['i8x16.gt_s', Int8Array, gt(-1)],
        ['i8x16.le_s', Int8Array, le(-1)],
        ['i8x16.ge_s', Int8Array, ge(-1)],
        ['i8x16.gt_u', Uint8Array, gt(0xFF)],
        ['i8x16.ge_u', Uint8Array, ge(0xFF)],