From e53b1dab31815a700325159268744a741f06463a Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 11 May 2016 11:51:41 -0700 Subject: [PATCH] Remove the minNum and maxNum functions. See discussion in #341. These two functions were added to correspond with the IEEE 754 functions of the same name. However, since EcmaScript doesn't distinguish quiet and signaling NaNs, it is non-trivial to achieve the exact same behavior as the IEEE functions. The SIMD.js min() and max() functions remain. They have the same behavior as Math.min() and Math.max(). --- src/ecmascript_simd.js | 30 ++--------------------- src/ecmascript_simd_tests.js | 18 -------------- tc39/spec.html | 46 ------------------------------------ 3 files changed, 2 insertions(+), 92 deletions(-) diff --git a/src/ecmascript_simd.js b/src/ecmascript_simd.js index a3de907..1e4f7ca 100644 --- a/src/ecmascript_simd.js +++ b/src/ecmascript_simd.js @@ -84,18 +84,6 @@ function isTypedArray(o) { (o instanceof Float64Array); } -function minNum(x, y) { - return x != x ? y : - y != y ? x : - Math.min(x, y); -} - -function maxNum(x, y) { - return x != x ? y : - y != y ? x : - Math.max(x, y); -} - function clamp(a, min, max) { if (a < min) return min; @@ -628,7 +616,7 @@ var float32x4 = { mulFn: binaryMul, fns: ["check", "splat", "replaceLane", "select", "equal", "notEqual", "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual", - "add", "sub", "mul", "div", "neg", "abs", "min", "max", "minNum", "maxNum", + "add", "sub", "mul", "div", "neg", "abs", "min", "max", "reciprocalApproximation", "reciprocalSqrtApproximation", "sqrt", "load", "load1", "load2", "load3", "store", "store1", "store2", "store3"], } @@ -872,7 +860,7 @@ if (typeof simdPhase2 !== 'undefined') { mulFn: binaryMul, fns: ["check", "splat", "replaceLane", "select", "equal", "notEqual", "lessThan", "lessThanOrEqual", "greaterThan", "greaterThanOrEqual", - "add", "sub", "mul", "div", "neg", "abs", "min", "max", "minNum", "maxNum", + "add", "sub", "mul", "div", "neg", "abs", "min", "max", "reciprocalApproximation", "reciprocalSqrtApproximation", "sqrt", "load", "store"], } @@ -1087,20 +1075,6 @@ var simdFns = { } }, - minNum: - function(type) { - return function(a, b) { - return simdBinaryOp(type, minNum, a, b); - } - }, - - maxNum: - function(type) { - return function(a, b) { - return simdBinaryOp(type, maxNum, a, b); - } - }, - load: function(type) { return function(tarray, index) { diff --git a/src/ecmascript_simd_tests.js b/src/ecmascript_simd_tests.js index 33ceffa..7dfdd16 100644 --- a/src/ecmascript_simd_tests.js +++ b/src/ecmascript_simd_tests.js @@ -18,18 +18,6 @@ 3. This notice may not be removed or altered from any source distribution. */ -function minNum(x, y) { - return x != x ? y : - y != y ? x : - Math.min(x, y); -} - -function maxNum(x, y) { - return x != x ? y : - y != y ? x : - Math.max(x, y); -} - function sameValue(x, y) { if (x == y) return x != 0 || y != 0 || (1/x == 1/y); @@ -943,12 +931,6 @@ simdTypes.filter(isFloatType).forEach(function(type) { test(type.name + ' max', function() { testBinaryOp(type, 'max', Math.max); }); - test(type.name + ' minNum', function() { - testBinaryOp(type, 'minNum', minNum); - }); - test(type.name + ' maxNum', function() { - testBinaryOp(type, 'maxNum', maxNum); - }); test(type.name + ' sqrt', function() { testUnaryOp(type, 'sqrt', function(a) { return Math.sqrt(a); }); }); diff --git a/tc39/spec.html b/tc39/spec.html index 3eabcd0..73e835b 100644 --- a/tc39/spec.html +++ b/tc39/spec.html @@ -841,30 +841,6 @@

MathMin(n, m)

- -

MaxNum(n, m)

- -1. Assert Type(_n_) is Number and Type(_m_) is Number. -1. If _n_ is *NaN*, return _m_. -1. If _m_ is *NaN*, return _n_. -1. Let _result_ be MathMax(_n_, _m_). -1. ReturnIfAbrupt(_result_). -1. Return _result_. - -
- - -

MinNum(n, m)

- -1. Assert Type(_n_) is Number and Type(_m_) is Number. -1. If _n_ is *NaN*, return _m_. -1. If _m_ is *NaN*, return _n_. -1. Let _result_ be MathMin(_n_, _m_). -1. ReturnIfAbrupt(_result_). -1. Return _result_. - -
-

ReciprocalApproximation(n)

Returns an implementation-dependent approximation to the reciprocal of _n_. @@ -1081,28 +1057,6 @@

_SIMD_Constructor.min(a, b)

- -

_SIMD_Constructor.maxNum(a, b)

-This operation is only defined on floating point SIMD types. - -1. If _a_.[[SIMDTypeDescriptor]] is not _SIMD_Descriptor or _b_.[[SIMDTypeDescriptor]] is not _SIMD_Descriptor, throw a TypeError exception. -1. Let _result_ be SIMDBinaryOp(_a_, _b_, MaxNum). -1. ReturnIfAbrupt(_result_). -1. Return _result_. - -
- - -

_SIMD_Constructor.minNum(a, b)

-This operation is only defined on floating point SIMD types. - -1. If _a_.[[SIMDTypeDescriptor]] is not _SIMD_Descriptor or _b_.[[SIMDTypeDescriptor]] is not _SIMD_Descriptor, throw a TypeError exception. -1. Let _result_ be SIMDBinaryOp(_a_, _b_, MinNum). -1. ReturnIfAbrupt(_result_). -1. Return _result_. - -
-

_SIMD_Constructor.neg(a)

This definition uses unary `-` to refer to the abstract operation defined by ES2015 12.5.10 (Unary - Operator).