Bug 1063946 SIMD: Group tests in logical units - conversions; r=bbouvier

--HG--
extra : rebase_source : f7bdd2a970afaf798d2d1093ad2f8316f7fe7659
This commit is contained in:
Florian Merz 2015-04-13 21:37:20 +02:00
Родитель eee7d61543
Коммит 7124413c0c
13 изменённых файлов: 184 добавлений и 466 удалений

Просмотреть файл

@ -0,0 +1,184 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var float32x4 = SIMD.float32x4;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
function testFloat32x4FromFloat64x2() {
function expected(v) {
return [...(v.map(Math.fround)), 0, 0];
}
var vals = [
[1, 2],
[-0, NaN],
[Infinity, -Infinity],
[Math.pow(2, 25) - 1, -Math.pow(25)],
[Math.pow(2, 1000), Math.pow(2, -1000)]
];
for (var v of vals) {
assertEqX4(float32x4.fromFloat64x2(float64x2(...v)), expected(v));
}
}
function testFloat32x4FromFloat64x2Bits() {
var valsExp = [
[[2.000000473111868, 512.0001225471497], [1.0, 2.0, 3.0, 4.0]],
[[-0, NaN], [0, -0, 0, NaN]],
[[Infinity, -Infinity], [0, NaN, 0, NaN]]
];
for (var [v,w] of valsExp) {
assertEqX4(float32x4.fromFloat64x2Bits(float64x2(...v)), w);
}
}
function testFloat32x4FromInt32x4() {
function expected(v) {
return v.map(Math.fround);
}
var vals = [
[1, 2, 3, 4],
[INT32_MIN, INT32_MAX, Math.pow(2, 30) - 1, -Math.pow(2, 30)]
];
for (var v of vals) {
assertEqX4(float32x4.fromInt32x4(int32x4(...v)), expected(v));
}
}
function testFloat32x4FromInt32x4Bits() {
var valsExp = [
[[100, 200, 300, 400], [1.401298464324817e-43, 2.802596928649634e-43, 4.203895392974451e-43, 5.605193857299268e-43]],
[[INT32_MIN, INT32_MAX, 0, 0], [-0, NaN, 0, 0]]
];
for (var [v,w] of valsExp) {
assertEqX4(float32x4.fromInt32x4Bits(int32x4(...v)), w);
}
}
function testFloat64x2FromFloat32x4() {
function expected(v) {
return v.slice(0, 2).map(Math.fround);
}
var vals = [
[100, 200, 300, 400],
[NaN, -0, NaN, -0],
[Infinity, -Infinity, Infinity, -Infinity],
[13.37, 12.853, 49.97, 53.124]
];
for (var v of vals) {
assertEqX2(float64x2.fromFloat32x4(float32x4(...v)), expected(v));
}
}
function testFloat64x2FromFloat32x4Bits() {
var valsExp = [
[[0, 1.875, 0, 2], [1.0, 2.0]],
[[NaN, -0, Infinity, -Infinity], [-1.058925634e-314, -1.404448428688076e+306]]
];
for (var [v,w] of valsExp) {
assertEqX2(float64x2.fromFloat32x4Bits(float32x4(...v)), w);
}
}
function testFloat64x2FromInt32x4() {
function expected(v) {
return v.slice(0, 2);
}
var vals = [
[1, 2, 3, 4],
[INT32_MAX, INT32_MIN, 0, 0]
];
for (var v of vals) {
assertEqX2(float64x2.fromInt32x4(int32x4(...v)), expected(v));
}
}
function testFloat64x2FromInt32x4Bits() {
var valsExp = [
[[0x00000000, 0x3ff00000, 0x0000000, 0x40000000], [1.0, 2.0]],
[[0xabcdef12, 0x3ff00000, 0x21fedcba, 0x40000000], [1.0000006400213732, 2.0000002532866263]]
];
for (var [v,w] of valsExp) {
assertEqX2(float64x2.fromInt32x4Bits(int32x4(...v)), w);
}
}
function testInt32x4FromFloat32x4() {
var valsExp = [
[[1.1, 2.2, 3.3, 4.6], [1, 2, 3, 4]],
[[NaN, -0, Infinity, -Infinity], [0, 0, 0, 0]]
];
for (var [v,w] of valsExp) {
assertEqX4(int32x4.fromFloat32x4(float32x4(...v)), w);
}
}
function testInt32x4FromFloat32x4Bits() {
var valsExp = [
[[1, 2, 3, 4], [0x3f800000 | 0, 0x40000000 | 0, 0x40400000 | 0, 0x40800000 | 0]],
[[NaN, -0, Infinity, -Infinity], [0x7fc00000 | 0, 0x80000000 | 0, 0x7f800000 | 0, 0xff800000 | 0]]
];
for (var [v,w] of valsExp) {
assertEqX4(int32x4.fromFloat32x4Bits(float32x4(...v)), w);
}
}
function testInt32x4FromFloat64x2() {
var valsExp = [
[[1, 2.2], [1, 2, 0, 0]],
[[NaN, -0], [0, 0, 0, 0]],
[[Infinity, -Infinity], [0, 0, 0, 0]],
[[Math.pow(2, 31), -Math.pow(2, 31) - 1], [INT32_MIN, INT32_MAX, 0, 0]]
];
for (var [v,w] of valsExp) {
assertEqX4(int32x4.fromFloat64x2(float64x2(...v)), w);
}
}
function testInt32x4FromFloat64x2Bits() {
var valsExp = [
[[1.0, 2.0], [0x00000000, 0x3FF00000, 0x00000000, 0x40000000]],
[[+Infinity, -Infinity], [0x00000000, 0x7ff00000, 0x00000000, -0x100000]],
[[-0, NaN], [0x00000000, -0x80000000, 0x00000000, 0x7ff80000]],
[[1.0000006400213732, 2.0000002532866263], [-0x543210ee, 0x3ff00000, 0x21fedcba, 0x40000000]]
];
for (var [v,w] of valsExp) {
assertEqX4(int32x4.fromFloat64x2Bits(float64x2(...v)), w);
}
}
function test() {
testFloat32x4FromFloat64x2();
testFloat32x4FromFloat64x2Bits();
testFloat32x4FromInt32x4();
testFloat32x4FromInt32x4Bits();
testFloat64x2FromFloat32x4();
testFloat64x2FromFloat32x4Bits();
testFloat64x2FromInt32x4();
testFloat64x2FromInt32x4Bits();
testInt32x4FromFloat32x4();
testInt32x4FromFloat32x4Bits();
testInt32x4FromFloat64x2();
testInt32x4FromFloat64x2Bits();
if (typeof reportCompare === "function") {
reportCompare(true, true);
}
}
test();

Просмотреть файл

@ -1,60 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float32x4 = SIMD.float32x4;
var float64x2 = SIMD.float64x2;
var summary = 'float32x4 fromFloat64x2';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = float64x2(1, 2);
var c = float32x4.fromFloat64x2(a);
assertEq(c.x, 1);
assertEq(c.y, 2);
assertEq(c.z, 0);
assertEq(c.w, 0);
var d = float64x2(-0, NaN);
var f = float32x4.fromFloat64x2(d);
assertEq(f.x, -0);
assertEq(f.y, NaN);
assertEq(f.z, 0);
assertEq(f.w, 0);
var g = float64x2(Infinity, -Infinity);
var i = float32x4.fromFloat64x2(g);
assertEq(i.x, Infinity);
assertEq(i.y, -Infinity);
assertEq(i.z, 0);
assertEq(i.w, 0);
var j = Math.pow(2, 25) - 1;
var k = -Math.pow(2, 25);
var l = float64x2(j, k);
var m = float32x4.fromFloat64x2(l);
assertEq(m.x, Math.fround(j));
assertEq(m.y, Math.fround(k));
assertEq(m.z, 0);
assertEq(m.w, 0);
var o = Math.pow(2, 1000);
var p = Math.pow(2, -1000);
var q = float64x2(o, p);
var r = float32x4.fromFloat64x2(q);
assertEq(r.x, Math.fround(o));
assertEq(r.y, Math.fround(p));
assertEq(r.z, 0);
assertEq(r.w, 0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,43 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float32x4 = SIMD.float32x4;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
var summary = 'float32x4 fromFloat64x2Bits';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = float64x2(2.000000473111868, 512.0001225471497);
var b = float32x4.fromFloat64x2Bits(a);
assertEq(b.x, 1.0);
assertEq(b.y, 2.0);
assertEq(b.z, 3.0);
assertEq(b.w, 4.0);
var c = float64x2(-0, NaN);
var d = float32x4.fromFloat64x2Bits(c);
assertEq(d.x, 0);
assertEq(d.y, -0);
assertEq(d.z, 0);
assertEq(d.w, NaN);
var e = float64x2(Infinity, -Infinity);
var f = float32x4.fromFloat64x2Bits(e);
assertEq(f.x, 0);
assertEq(f.y, NaN);
assertEq(f.z, 0);
assertEq(f.w, NaN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,35 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 946042;
var float32x4 = SIMD.float32x4;
var int32x4 = SIMD.int32x4;
var summary = 'float32x4 fromInt32x4';
function test() {
print(BUGNUMBER + ": " + summary);
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);
assertEq(c.x, 1);
assertEq(c.y, 2);
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);
}
test();

Просмотреть файл

@ -1,33 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 946042;
var float32x4 = SIMD.float32x4;
var int32x4 = SIMD.int32x4;
var summary = 'float32x4 fromInt32x4Bits';
function test() {
print(BUGNUMBER + ": " + summary);
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);
assertEq(c.x, 1.401298464324817e-43);
assertEq(c.y, 2.802596928649634e-43);
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);
}
test();

Просмотреть файл

@ -1,41 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float32x4 = SIMD.float32x4;
var float64x2 = SIMD.float64x2;
var summary = 'float64x2 fromFloat32x4';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = float32x4(100, 200, 300, 400);
var c = float64x2.fromFloat32x4(a);
assertEq(c.x, 100);
assertEq(c.y, 200);
var d = float32x4(NaN, -0, NaN, -0);
var f = float64x2.fromFloat32x4(d);
assertEq(f.x, NaN);
assertEq(f.y, -0);
var g = float32x4(Infinity, -Infinity, Infinity, -Infinity);
var i = float64x2.fromFloat32x4(g);
assertEq(i.x, Infinity);
assertEq(i.y, -Infinity);
var j = float32x4(13.37, 12.853, 49.97, 53.124);
var l = float64x2.fromFloat32x4(j);
assertEq(l.x, Math.fround(13.37));
assertEq(l.y, Math.fround(12.853));
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,32 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float32x4 = SIMD.float32x4;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
var summary = 'float64x2 fromFloat32x4Bits';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = float32x4(0, 1.875, 0, 2);
var c = float64x2.fromFloat32x4Bits(a);
assertEq(c.x, 1.0);
assertEq(c.y, 2.0);
var d = float32x4(NaN, -0, Infinity, -Infinity);
var f = float64x2.fromFloat32x4Bits(d);
assertEq(f.x, -1.058925634e-314);
assertEq(f.y, -1.404448428688076e+306);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,31 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
var summary = 'float64x2 fromInt32x4';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = int32x4(1, 2, 3, 4);
var c = float64x2.fromInt32x4(a);
assertEq(c.x, 1);
assertEq(c.y, 2);
var d = int32x4(INT32_MAX, INT32_MIN, 0, 0);
var f = float64x2.fromInt32x4(d);
assertEq(f.x, INT32_MAX);
assertEq(f.y, INT32_MIN);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,31 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
var summary = 'float64x2 fromInt32x4Bits';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = int32x4(0x00000000, 0x3ff00000, 0x0000000, 0x40000000);
var c = float64x2.fromInt32x4Bits(a);
assertEq(c.x, 1.0);
assertEq(c.y, 2.0);
var d = int32x4(0xabcdef12, 0x3ff00000, 0x21fedcba, 0x40000000);
var f = float64x2.fromInt32x4Bits(d);
assertEq(f.x, 1.0000006400213732);
assertEq(f.y, 2.0000002532866263);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,30 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 946042;
var float32x4 = SIMD.float32x4;
var int32x4 = SIMD.int32x4;
var summary = 'int32x4 fromFloat32x4';
function test() {
print(BUGNUMBER + ": " + summary);
var a = float32x4(1.1, 2.2, 3.3, 4.6);
var c = SIMD.int32x4.fromFloat32x4(a);
assertEq(c.x, 1);
assertEq(c.y, 2);
assertEq(c.z, 3);
assertEq(c.w, 4);
var d = float32x4(NaN, -0, Infinity, -Infinity);
var f = SIMD.int32x4.fromFloat32x4(d);
assertEq(f.x, 0);
assertEq(f.y, 0);
assertEq(f.z, 0);
assertEq(f.w, 0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,30 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 946042;
var float32x4 = SIMD.float32x4;
var int32x4 = SIMD.int32x4;
var summary = 'int32x4 fromFloat32x4Bits';
function test() {
print(BUGNUMBER + ": " + summary);
var a = float32x4(1, 2, 3, 4);
var c = SIMD.int32x4.fromFloat32x4Bits(a);
assertEq(c.x, 0x3f800000 | 0);
assertEq(c.y, 0x40000000 | 0);
assertEq(c.z, 0x40400000 | 0);
assertEq(c.w, 0x40800000 | 0);
var d = float32x4(NaN, -0, Infinity, -Infinity);
var f = SIMD.int32x4.fromFloat32x4Bits(d);
assertEq(f.x, 0x7fc00000 | 0);
assertEq(f.y, 0x80000000 | 0);
assertEq(f.z, 0x7f800000 | 0);
assertEq(f.w, 0xff800000 | 0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,51 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
var summary = 'int32x4 fromFloat64x2';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = float64x2(1, 2.2);
var c = int32x4.fromFloat64x2(a);
assertEq(c.x, 1);
assertEq(c.y, 2);
assertEq(c.z, 0);
assertEq(c.w, 0);
var d = float64x2(NaN, -0);
var f = int32x4.fromFloat64x2(d);
assertEq(f.x, 0);
assertEq(f.y, 0);
assertEq(f.z, 0);
assertEq(f.w, 0);
var g = float64x2(Infinity, -Infinity);
var i = int32x4.fromFloat64x2(g);
assertEq(i.x, 0);
assertEq(i.y, 0);
assertEq(i.z, 0);
assertEq(i.w, 0);
var j = Math.pow(2, 31);
var k = -Math.pow(2, 31) - 1;
var m = float64x2(j, k);
var l = int32x4.fromFloat64x2(m);
assertEq(l.x, INT32_MIN);
assertEq(l.y, INT32_MAX);
assertEq(l.z, 0);
assertEq(l.w, 0);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();

Просмотреть файл

@ -1,49 +0,0 @@
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))
var BUGNUMBER = 1031203;
var float64x2 = SIMD.float64x2;
var int32x4 = SIMD.int32x4;
var summary = 'int32x4 fromFloat64x2Bits';
/*
* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
print(BUGNUMBER + ": " + summary);
var a = float64x2(1.0, 2.0);
var c = int32x4.fromFloat64x2Bits(a);
assertEq(c.x, 0x00000000);
assertEq(c.y, 0x3FF00000);
assertEq(c.z, 0x00000000);
assertEq(c.w, 0x40000000);
var d = float64x2(+Infinity, -Infinity);
var f = int32x4.fromFloat64x2Bits(d);
assertEq(f.x, 0x00000000);
assertEq(f.y, 0x7ff00000);
assertEq(f.z, 0x00000000);
assertEq(f.w, -0x100000);
var g = float64x2(-0, NaN);
var i = int32x4.fromFloat64x2Bits(g);
assertEq(i.x, 0x00000000);
assertEq(i.y, -0x80000000);
assertEq(i.z, 0x00000000);
assertEq(i.w, 0x7ff80000);
var j = float64x2(1.0000006400213732, 2.0000002532866263);
var l = int32x4.fromFloat64x2Bits(j);
assertEq(l.x, -0x543210ee);
assertEq(l.y, 0x3ff00000);
assertEq(l.z, 0x21fedcba);
assertEq(l.w, 0x40000000);
if (typeof reportCompare === "function")
reportCompare(true, true);
}
test();