Bug 948379 - added float32x4 border cases. r=bbouvier

This commit is contained in:
ProgramFOX 2014-10-22 16:30:14 +02:00
parent ca40a01d83
commit 740407faa1
27 changed files with 438 additions and 55 deletions

View File

@ -466,7 +466,7 @@ namespace js {
// Unary SIMD operators
template<typename T>
struct Abs {
static inline T apply(T x) { return x < 0 ? -1 * x : x; }
static inline T apply(T x) { return mozilla::Abs(x); }
};
template<typename T>
struct Neg {

View File

@ -8,8 +8,6 @@ var summary = 'float32x4 abs';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(-1, 2, -3, 4);
var c = SIMD.float32x4.abs(a);
assertEq(c.x, 1);
@ -17,6 +15,20 @@ function test() {
assertEq(c.z, 3);
assertEq(c.w, 4);
var d = float32x4(-1.63, 2.46, -3.17, 4.94);
var f = SIMD.float32x4.abs(d);
assertEq(f.x, Math.fround(1.63));
assertEq(f.y, Math.fround(2.46));
assertEq(f.z, Math.fround(3.17));
assertEq(f.w, Math.fround(4.94));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.abs(g);
assertEq(i.x, NaN);
assertEq(i.y, 0);
assertEq(i.z, Infinity);
assertEq(i.w, Infinity);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -5,11 +5,13 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 add';
function addf(a, b) {
return Math.fround(Math.fround(a) + Math.fround(b));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.add(a, b);
@ -18,6 +20,22 @@ function test() {
assertEq(c.z, 33);
assertEq(c.w, 44);
var d = float32x4(1.57, 2.27, 3.57, 4.19);
var e = float32x4(10.31, 20.49, 30.41, 40.72);
var f = SIMD.float32x4.add(d, e);
assertEq(f.x, addf(1.57, 10.31));
assertEq(f.y, addf(2.27, 20.49));
assertEq(f.z, addf(3.57, 30.41));
assertEq(f.w, addf(4.19, 40.72));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var h = float32x4(0, -0, -Infinity, -Infinity);
var i = SIMD.float32x4.add(g, h);
assertEq(i.x, NaN);
assertEq(i.y, -0);
assertEq(i.z, NaN);
assertEq(i.w, -Infinity);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -19,8 +19,6 @@ var andf = (function() {
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.and(a, b);
@ -29,6 +27,22 @@ function test() {
assertEq(c.z, andf(3, 30));
assertEq(c.w, andf(4, 40));
var d = float32x4(1.51, 2.98, 3.65, 4.34);
var e = float32x4(10.29, 20.12, 30.79, 40.41);
var f = SIMD.float32x4.and(d, e);
assertEq(f.x, andf(1.51, 10.29));
assertEq(f.y, andf(2.98, 20.12));
assertEq(f.z, andf(3.65, 30.79));
assertEq(f.w, andf(4.34, 40.41));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var h = float32x4(NaN, -0, -Infinity, Infinity);
var i = SIMD.float32x4.and(g, h);
assertEq(i.x, NaN);
assertEq(i.y, -0);
assertEq(i.z, Infinity);
assertEq(i.w, Infinity);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -8,14 +8,34 @@ var summary = 'float32x4 clamp';
function test() {
print(BUGNUMBER + ": " + summary);
var a = float32x4(-13.37, 10.46, 31.79, 0.54);
var lower = float32x4(2.1, 1.1, 50.13, 0.0);
var upper = float32x4(2.56, 5.55, 55.93, 1.1);
// FIXME -- Bug 1068028: Amend to check for correctness of NaN border cases once the semantics are defined.
var a = float32x4(-20, 10, 30, 0.5);
var lower = float32x4(2, 1, 50, 0);
var upper = float32x4(2.5, 5, 55, 1);
var c = SIMD.float32x4.clamp(a, lower, upper);
assertEq(c.x, Math.fround(2.1));
assertEq(c.y, Math.fround(5.55));
assertEq(c.z, Math.fround(50.13));
assertEq(c.w, Math.fround(0.54));
assertEq(c.x, 2);
assertEq(c.y, 5);
assertEq(c.z, 50);
assertEq(c.w, 0.5);
var d = float32x4(-13.37, 10.46, 31.79, 0.54);
var lower1 = float32x4(2.1, 1.1, 50.13, 0.0);
var upper1 = float32x4(2.56, 5.55, 55.93, 1.1);
var f = SIMD.float32x4.clamp(d, lower1, upper1);
assertEq(f.x, Math.fround(2.1));
assertEq(f.y, Math.fround(5.55));
assertEq(f.z, Math.fround(50.13));
assertEq(f.w, Math.fround(0.54));
var g = float32x4(4, -Infinity, 10, -10);
var lower2 = float32x4(5, -Infinity, -Infinity, -Infinity);
var upper2 = float32x4(Infinity, 5, Infinity, Infinity);
var i = SIMD.float32x4.clamp(g, lower2, upper2);
assertEq(i.x, 5);
assertEq(i.y, -Infinity);
assertEq(i.z, 10);
assertEq(i.w, -10);
if (typeof reportCompare === "function")
reportCompare(true, true);

View File

@ -5,22 +5,39 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 div';
function divf(a, b) {
return Math.fround(Math.fround(a) / Math.fround(b));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.div(b,a);
var c = SIMD.float32x4.div(b, a);
assertEq(c.x, 10);
assertEq(c.y, 10);
assertEq(c.z, 10);
assertEq(c.w, 10);
var d = float32x4(1.26, 2.03, 3.17, 4.59);
var e = float32x4(11.025, 17.3768, 29.1957, 46.4049);
var f = SIMD.float32x4.div(e, d);
assertEq(f.x, divf(11.025, 1.26));
assertEq(f.y, divf(17.3768, 2.03));
assertEq(f.z, divf(29.1957, 3.17));
assertEq(f.w, divf(46.4049, 4.59));
var g = float32x4(0, -0, Infinity, -Infinity);
var h = float32x4(1, 1, -Infinity, Infinity);
var i = SIMD.float32x4.div(h, g);
assertEq(i.x, Infinity);
assertEq(i.y, -Infinity);
assertEq(i.z, NaN);
assertEq(i.w, NaN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

View File

@ -8,7 +8,7 @@ var summary = 'float32x4 equal';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
@ -18,6 +18,14 @@ function test() {
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);
}

View File

@ -8,7 +8,8 @@ var summary = 'float32x4 fromInt32x4';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var INT32_MAX = Math.pow(2, 31) - 1;
var INT32_MIN = -Math.pow(2, 31);
var a = int32x4(1, 2, 3, 4);
var c = SIMD.float32x4.fromInt32x4(a);
@ -17,6 +18,15 @@ function test() {
assertEq(c.z, 3);
assertEq(c.w, 4);
var value1 = Math.pow(2, 30) - 1;
var value2 = -Math.pow(2, 30);
var d = int32x4(INT32_MIN, INT32_MAX, value1, value2);
var f = float32x4.fromInt32x4(d);
assertEq(f.x, Math.fround(INT32_MIN));
assertEq(f.y, Math.fround(INT32_MAX));
assertEq(f.z, Math.fround(value1));
assertEq(f.w, Math.fround(value2));
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -8,7 +8,8 @@ var summary = 'float32x4 fromInt32x4Bits';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var INT32_MAX = Math.pow(2, 31) - 1;
var INT32_MIN = -Math.pow(2, 31);
var a = int32x4(100, 200, 300, 400);
var c = SIMD.float32x4.fromInt32x4Bits(a);
@ -17,6 +18,13 @@ function test() {
assertEq(c.z, 4.203895392974451e-43);
assertEq(c.w, 5.605193857299268e-43);
var d = int32x4(INT32_MIN, INT32_MAX, 0, 0);
var f = float32x4.fromInt32x4Bits(d);
assertEq(f.x, -0);
assertEq(f.y, NaN);
assertEq(f.z, 0);
assertEq(f.w, 0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -8,16 +8,25 @@ var summary = 'float32x4 greaterThan';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
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);
}

View File

@ -8,16 +8,25 @@ var summary = 'float32x4 greaterThanOrEqual';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
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);
}

View File

@ -8,7 +8,8 @@ var summary = 'float32x4 lessThan';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
@ -18,6 +19,14 @@ function test() {
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);
}

View File

@ -8,7 +8,8 @@ var summary = 'float32x4 lessThanOrEqual';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
@ -18,6 +19,14 @@ function test() {
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);
}

View File

@ -8,7 +8,8 @@ var summary = 'float32x4 max';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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, 4);
var b = float32x4(10, 2, 3, 40);
@ -18,6 +19,14 @@ function test() {
assertEq(c.z, 30);
assertEq(c.w, 40);
var d = float32x4(9.999, 2.1234, 30.4443, 4);
var e = float32x4(10, 2.1233, 30.4444, 4.0001);
var f = float32x4.max(d, e);
assertEq(f.x, 10);
assertEq(f.y, Math.fround(2.1234));
assertEq(f.z, Math.fround(30.4444));
assertEq(f.w, Math.fround(4.0001));
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -8,7 +8,8 @@ var summary = 'float32x4 min';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
@ -18,6 +19,14 @@ function test() {
assertEq(c.z, 3);
assertEq(c.w, 4);
var d = float32x4(1.4321, 20.5567, 30.8999, 4.0002);
var e = float32x4(1.432, 20.5568, 30.8998, 4.0001);
var f = float32x4.min(d, e);
assertEq(f.x, Math.fround(1.432));
assertEq(f.y, Math.fround(20.5567));
assertEq(f.z, Math.fround(30.8998));
assertEq(f.w, Math.fround(4.0001));
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -3,13 +3,15 @@ var BUGNUMBER = 946042;
var float32x4 = SIMD.float32x4;
var int32x4 = SIMD.int32x4;
var summary = 'float32x4 add';
var summary = 'float32x4 mul';
function mulf(a, b) {
return Math.fround(Math.fround(a) * Math.fround(b));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.mul(a, b);
@ -18,9 +20,24 @@ function test() {
assertEq(c.z, 90);
assertEq(c.w, 160);
var d = float32x4(1.66, 2.57, 3.73, 4.12);
var e = float32x4(10.67, 20.68, 30.02, 40.58);
var f = SIMD.float32x4.mul(d, e);
assertEq(f.x, mulf(1.66, 10.67));
assertEq(f.y, mulf(2.57, 20.68));
assertEq(f.z, mulf(3.73, 30.02));
assertEq(f.w, mulf(4.12, 40.58));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var h = float32x4(NaN, -0, -Infinity, 0);
var i = SIMD.float32x4.mul(g, h);
assertEq(i.x, NaN);
assertEq(i.y, 0);
assertEq(i.z, -Infinity);
assertEq(i.w, NaN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

View File

@ -8,8 +8,6 @@ var summary = 'float32x4 neg';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var c = SIMD.float32x4.neg(a);
assertEq(c.x, -1);
@ -17,6 +15,20 @@ function test() {
assertEq(c.z, -3);
assertEq(c.w, -4);
var d = float32x4(0.999, -0.001, 3.78, 4.05);
var f = SIMD.float32x4.neg(d);
assertEq(f.x, Math.fround(-0.999));
assertEq(f.y, Math.fround(0.001));
assertEq(f.z, Math.fround(-3.78));
assertEq(f.w, Math.fround(-4.05));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.neg(g);
assertEq(i.x, NaN);
assertEq(i.y, 0);
assertEq(i.z, -Infinity);
assertEq(i.w, Infinity);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -18,8 +18,6 @@ var notf = (function() {
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(2, 13, -37, 4.2);
var c = SIMD.float32x4.not(a);
assertEq(c.x, notf(2));
@ -27,6 +25,20 @@ function test() {
assertEq(c.z, notf(-37));
assertEq(c.w, notf(4.2));
var d = float32x4(2.897, 13.245, -37.781, 5.28);
var f = SIMD.float32x4.not(d);
assertEq(f.x, notf(2.897));
assertEq(f.y, notf(13.245));
assertEq(f.z, notf(-37.781));
assertEq(f.w, notf(5.28));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.not(g);
assertEq(i.x, notf(NaN));
assertEq(i.y, notf(-0));
assertEq(i.z, notf(Infinity));
assertEq(i.w, notf(-Infinity));
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -8,7 +8,7 @@ var summary = 'float32x4 notEqual';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
// 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);
@ -18,6 +18,14 @@ function test() {
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);
}

View File

@ -19,8 +19,6 @@ var orf = (function() {
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.or(a, b);
@ -29,6 +27,22 @@ function test() {
assertEq(c.z, orf(3, 30));
assertEq(c.w, orf(4, 40));
var d = float32x4(1.12, 2.39, 3.83, 4.57);
var e = float32x4(10.76, 20.41, 30.96, 40.23);
var f = SIMD.float32x4.or(d, e);
assertEq(f.x, orf(1.12, 10.76));
assertEq(f.y, orf(2.39, 20.41));
assertEq(f.z, orf(3.83, 30.96));
assertEq(f.w, orf(4.57, 40.23));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var h = float32x4(5, 5, -Infinity, Infinity);
var i = SIMD.float32x4.or(g, h);
assertEq(i.x, orf(NaN, 5));
assertEq(i.y, orf(-0, 5));
assertEq(i.z, orf(Infinity, -Infinity));
assertEq(i.w, orf(-Infinity, Infinity));
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -5,11 +5,13 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 reciprocal';
function reciprocalf(a) {
return Math.fround(1 / Math.fround(a));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 0.5, 0.25, 0.125);
var c = SIMD.float32x4.reciprocal(a);
assertEq(c.x, 1);
@ -17,6 +19,20 @@ function test() {
assertEq(c.z, 4);
assertEq(c.w, 8);
var d = float32x4(1.6, 0.8, 0.4, 0.2);
var f = SIMD.float32x4.reciprocal(d);
assertEq(f.x, reciprocalf(1.6));
assertEq(f.y, reciprocalf(0.8));
assertEq(f.z, reciprocalf(0.4));
assertEq(f.w, reciprocalf(0.2));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.reciprocal(g);
assertEq(i.x, NaN);
assertEq(i.y, -Infinity);
assertEq(i.z, 0);
assertEq(i.w, -0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -5,11 +5,13 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 reciprocalSqrt';
function reciprocalsqrtf(a) {
return Math.fround(Math.sqrt(1 / Math.fround(a)));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 1, 0.25, 0.25);
var c = SIMD.float32x4.reciprocalSqrt(a);
assertEq(c.x, 1);
@ -17,6 +19,20 @@ function test() {
assertEq(c.z, 2);
assertEq(c.w, 2);
var d = float32x4(25, 16, 6.25, 1.5625);
var f = SIMD.float32x4.reciprocalSqrt(d);
assertEq(f.x, reciprocalsqrtf(25));
assertEq(f.y, reciprocalsqrtf(16));
assertEq(f.z, reciprocalsqrtf(6.25));
assertEq(f.w, reciprocalsqrtf(1.5625));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.reciprocalSqrt(g);
assertEq(i.x, NaN);
assertEq(i.y, -Infinity);
assertEq(i.z, 0);
assertEq(i.w, NaN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -5,11 +5,13 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 scale';
function mulf(a, b) {
return Math.fround(Math.fround(a) * Math.fround(b));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var c = SIMD.float32x4.scale(a, 2);
assertEq(c.x, 2);
@ -17,6 +19,20 @@ function test() {
assertEq(c.z, 6);
assertEq(c.w, 8);
var d = float32x4(1.34, 2.76, 3.21, 4.09);
var f = float32x4.scale(d, 2.54);
assertEq(f.x, mulf(1.34, 2.54));
assertEq(f.y, mulf(2.76, 2.54));
assertEq(f.z, mulf(3.21, 2.54));
assertEq(f.w, mulf(4.09, 2.54));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = float32x4.scale(g, 2.54);
assertEq(i.x, NaN);
assertEq(i.y, -0);
assertEq(i.z, Infinity);
assertEq(i.w, -Infinity);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -5,11 +5,13 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 sqrt';
function sqrtf(a) {
return Math.fround(Math.sqrt(Math.fround(a)));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 4, 9, 16);
var c = SIMD.float32x4.sqrt(a);
assertEq(c.x, 1);
@ -17,6 +19,20 @@ function test() {
assertEq(c.z, 3);
assertEq(c.w, 4);
var d = float32x4(2.7225, 7.3441, 9.4249, -1);
var f = SIMD.float32x4.sqrt(d);
assertEq(f.x, sqrtf(2.7225));
assertEq(f.y, sqrtf(7.3441));
assertEq(f.z, sqrtf(9.4249));
assertEq(f.w, NaN);
var g = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.sqrt(g);
assertEq(i.x, NaN);
assertEq(i.y, -0);
assertEq(i.z, Infinity);
assertEq(i.w, NaN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -5,19 +5,37 @@ var int32x4 = SIMD.int32x4;
var summary = 'float32x4 sub';
function subf(a, b) {
return Math.fround(Math.fround(a) - Math.fround(b));
}
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.sub(b,a);
var c = SIMD.float32x4.sub(b, a);
assertEq(c.x, 9);
assertEq(c.y, 18);
assertEq(c.z, 27);
assertEq(c.w, 36);
var d = float32x4(1.34, 2.95, 3.17, 4.29);
var e = float32x4(10.18, 20.43, 30.63, 40.38);
var f = SIMD.float32x4.sub(e, d);
assertEq(f.x, subf(10.18, 1.34));
assertEq(f.y, subf(20.43, 2.95));
assertEq(f.z, subf(30.63, 3.17));
assertEq(f.w, subf(40.38, 4.29));
var g = float32x4(NaN, -0, -Infinity, -Infinity);
var h = float32x4(NaN, -0, Infinity, -Infinity);
var i = SIMD.float32x4.sub(h, g);
assertEq(i.x, NaN);
assertEq(i.y, 0);
assertEq(i.z, Infinity);
assertEq(i.w, NaN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -8,18 +8,81 @@ var summary = 'float32x4 with';
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var x = SIMD.float32x4.withX(a, 5);
var y = SIMD.float32x4.withY(a, 5);
var z = SIMD.float32x4.withZ(a, 5);
var w = SIMD.float32x4.withW(a, 5);
assertEq(x.x, 5);
assertEq(x.y, 2);
assertEq(x.z, 3);
assertEq(x.w, 4);
assertEq(y.x, 1);
assertEq(y.y, 5);
assertEq(y.z, 3);
assertEq(y.w, 4);
assertEq(z.x, 1);
assertEq(z.y, 2);
assertEq(z.z, 5);
assertEq(z.w, 4);
assertEq(w.x, 1);
assertEq(w.y, 2);
assertEq(w.z, 3);
assertEq(w.w, 5);
var b = float32x4(1.87, 2.08, 3.84, 4.17);
var x1 = SIMD.float32x4.withX(b, 5.38);
var y1 = SIMD.float32x4.withY(b, 5.19);
var z1 = SIMD.float32x4.withZ(b, 5.11);
var w1 = SIMD.float32x4.withW(b, 5.07);
assertEq(x1.x, Math.fround(5.38));
assertEq(x1.y, Math.fround(2.08));
assertEq(x1.z, Math.fround(3.84));
assertEq(x1.w, Math.fround(4.17));
assertEq(y1.x, Math.fround(1.87));
assertEq(y1.y, Math.fround(5.19));
assertEq(y1.z, Math.fround(3.84));
assertEq(y1.w, Math.fround(4.17));
assertEq(z1.x, Math.fround(1.87));
assertEq(z1.y, Math.fround(2.08));
assertEq(z1.z, Math.fround(5.11));
assertEq(z1.w, Math.fround(4.17));
assertEq(w1.x, Math.fround(1.87));
assertEq(w1.y, Math.fround(2.08));
assertEq(w1.z, Math.fround(3.84));
assertEq(w1.w, Math.fround(5.07));
var c = float32x4(NaN, -0, Infinity, -Infinity);
var x2 = SIMD.float32x4.withX(c, 0);
var y2 = SIMD.float32x4.withY(c, 0);
var z2 = SIMD.float32x4.withZ(c, 0);
var w2 = SIMD.float32x4.withW(c, 0);
assertEq(x2.x, 0);
assertEq(x2.y, -0);
assertEq(x2.z, Infinity);
assertEq(x2.w, -Infinity);
assertEq(y2.x, NaN);
assertEq(y2.y, 0);
assertEq(y2.z, Infinity);
assertEq(y2.w, -Infinity);
assertEq(z2.x, NaN);
assertEq(z2.y, -0);
assertEq(z2.z, 0);
assertEq(z2.w, -Infinity);
assertEq(w2.x, NaN);
assertEq(w2.y, -0);
assertEq(w2.z, Infinity);
assertEq(w2.w, 0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}

View File

@ -19,8 +19,6 @@ var xorf = (function() {
function test() {
print(BUGNUMBER + ": " + summary);
// FIXME -- Bug 948379: Amend to check for correctness of border cases.
var a = float32x4(1, 2, 3, 4);
var b = float32x4(10, 20, 30, 40);
var c = SIMD.float32x4.xor(a, b);
@ -29,6 +27,22 @@ function test() {
assertEq(c.z, xorf(3, 30));
assertEq(c.w, xorf(4, 40));
var d = float32x4(1.07, 2.62, 3.79, 4.15);
var e = float32x4(10.38, 20.47, 30.44, 40.16);
var f = SIMD.float32x4.xor(d, e);
assertEq(f.x, xorf(1.07, 10.38));
assertEq(f.y, xorf(2.62, 20.47));
assertEq(f.z, xorf(3.79, 30.44));
assertEq(f.w, xorf(4.15, 40.16));
var g = float32x4(NaN, -0, Infinity, -Infinity);
var h = float32x4(-0, Infinity, -Infinity, NaN);
var i = SIMD.float32x4.xor(g, h);
assertEq(i.x, xorf(NaN, -0));
assertEq(i.y, xorf(-0, Infinity));
assertEq(i.z, xorf(Infinity, -Infinity));
assertEq(i.w, xorf(-Infinity, NaN));
if (typeof reportCompare === "function")
reportCompare(true, true);
}