Bug 1657628 - Fix bugs in some ad-hack simd tests. r=jseward
authorLars T Hansen <lhansen@mozilla.com>
Wed, 12 Aug 2020 13:10:50 +0000
changeset 544396 5c9edf20c00433845e32eae8fd6251bbfaaac321
parent 544395 2d73a015caaa3e70c175172158a6548625dc6da3
child 544397 f1cdbe186a1598e59f64a740b63f0dcf27e7a22f
push id37694
push userdluca@mozilla.com
push dateWed, 12 Aug 2020 21:49:48 +0000
treeherdermozilla-central@74b3be6fcb93 [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)],