Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

Commit b85f7aa

Browse files
committed
Merge pull request #77 from bnjbvr/remove-emulated
Remove instructions that can be emulated, fixes #68
2 parents 7e81ccc + 4320a35 commit b85f7aa

7 files changed

+14
-201
lines changed

src/benchmarks/aobench.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
orthoBasis(basis, isect.n);
279279

280280
var occlusion = 0;
281-
var occlusionx4 = SIMD.float32x4.zero();
281+
var occlusionx4 = SIMD.float32x4.splat(0.0);
282282

283283
for (j = 0; j < ntheta; j++) {
284284
for (i = 0; i < nphi; i += 4) {
@@ -314,14 +314,14 @@
314314
};
315315
var occIsectB = {
316316
p: {
317-
x: SIMD.float32x4.zero(),
318-
y: SIMD.float32x4.zero(),
319-
z: SIMD.float32x4.zero()
317+
x: SIMD.float32x4.splat(0.0),
318+
y: SIMD.float32x4.splat(0.0),
319+
z: SIMD.float32x4.splat(0.0)
320320
},
321321
n: {
322-
x: SIMD.float32x4.zero(),
323-
y: SIMD.float32x4.zero(),
324-
z: SIMD.float32x4.zero()
322+
x: SIMD.float32x4.splat(0.0),
323+
y: SIMD.float32x4.splat(0.0),
324+
z: SIMD.float32x4.splat(0.0)
325325
}
326326
};
327327

@@ -363,10 +363,10 @@
363363
SIMD.float32x4.splat(sphere.radius * sphere.radius));
364364
var D = SIMD.float32x4.sub(SIMD.float32x4.mul(B, B), C);
365365

366-
var cond1 = SIMD.float32x4.greaterThan(D, SIMD.float32x4.zero());
366+
var cond1 = SIMD.float32x4.greaterThan(D, SIMD.float32x4.splat(0.0));
367367
if (cond1.signMask) {
368368
var t2 = SIMD.float32x4.fromInt32x4Bits(SIMD.int32x4.and(cond1, SIMD.int32x4.fromFloat32x4Bits(SIMD.float32x4.sub(SIMD.float32x4.neg(B), SIMD.float32x4.sqrt(D)))));
369-
var cond2 = SIMD.int32x4.and(SIMD.float32x4.greaterThan(t2, SIMD.float32x4.zero()),
369+
var cond2 = SIMD.int32x4.and(SIMD.float32x4.greaterThan(t2, SIMD.float32x4.splat(0.0)),
370370
SIMD.float32x4.lessThan(t2, isectA.t));
371371
if (cond2.signMask) {
372372
isectA.t = SIMD.float32x4.fromInt32x4Bits(
@@ -428,7 +428,7 @@
428428
SIMD.float32x4.add(SIMD.float32x4.mul(orgy, SIMD.float32x4.splat(plane.n.y)),
429429
SIMD.float32x4.mul(orgz, SIMD.float32x4.splat(plane.n.z))));
430430
var t2 = SIMD.float32x4.fromInt32x4Bits(SIMD.int32x4.and(cond1, SIMD.int32x4.fromFloat32x4Bits(SIMD.float32x4.div(SIMD.float32x4.neg(SIMD.float32x4.add(dp, d)), v))));
431-
var cond2 = SIMD.int32x4.and(SIMD.float32x4.greaterThan(t2, SIMD.float32x4.zero()), SIMD.float32x4.lessThan(t2, isectA.t));
431+
var cond2 = SIMD.int32x4.and(SIMD.float32x4.greaterThan(t2, SIMD.float32x4.splat(0.0)), SIMD.float32x4.lessThan(t2, isectA.t));
432432
if (cond2.signMask) {
433433
isectA.t = SIMD.float32x4.fromInt32x4Bits(SIMD.int32x4.or(SIMD.int32x4.and(cond2, SIMD.int32x4.fromFloat32x4Bits(t2)),
434434
SIMD.int32x4.and(SIMD.int32x4.not(cond2), SIMD.int32x4.fromFloat32x4Bits(isectA.t))));

src/benchmarks/averageFloat32x4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
function simdAverage(n) {
5454
var ax4_length = ax4.length;
5555
for (var i = 0; i < n; ++i) {
56-
var sum4 = SIMD.float32x4.zero();
56+
var sum4 = SIMD.float32x4.splat(0.0);
5757
for (var j = 0; j < ax4_length; ++j) {
5858
sum4 = SIMD.float32x4.add(sum4, ax4.getAt(j));
5959
}

src/benchmarks/averageFloat64x2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
function simdAverage(n) {
5555
var ax2_length = ax2.length;
5656
for (var i = 0; i < n; ++i) {
57-
var sum2 = SIMD.float64x2.zero();
57+
var sum2 = SIMD.float64x2.splat(0.0);
5858
for (var j = 0; j < ax2_length; ++j) {
5959
sum2 = SIMD.float64x2.add(sum2, ax2.getAt(j));
6060
}

src/benchmarks/sinx4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
emm0 = SIMD.int32x4.shiftLeftByScalar(emm0, 29);
122122

123123
emm2 = SIMD.int32x4.and(emm2, _pi32_2);
124-
emm2 = SIMD.int32x4.equal(emm2, SIMD.int32x4.zero());
124+
emm2 = SIMD.int32x4.equal(emm2, SIMD.int32x4.splat(0));
125125

126126
swap_sign_bit = SIMD.float32x4.fromInt32x4Bits(emm0);
127127
poly_mask = SIMD.float32x4.fromInt32x4Bits(emm2);

src/benchmarks/transform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
function simdVertexTransform(n) {
8181
for (var i = 0; i < n; i++) {
8282
var xxxx = SIMD.float32x4.shuffle(Vx4.getAt(0), SIMD.XXXX);
83-
var z = SIMD.float32x4.zero();
83+
var z = SIMD.float32x4.splat(0.0);
8484
z = SIMD.float32x4.add(z, SIMD.float32x4.mul(xxxx, Tx4.getAt(0)));
8585
var yyyy = SIMD.float32x4.shuffle(Vx4.getAt(0), SIMD.YYYY);
8686
z = SIMD.float32x4.add(z, SIMD.float32x4.mul(yyyy, Tx4.getAt(1)));

src/ecmascript_simd.js

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ SIMD.float32x4 = function(x, y, z, w) {
9898
this.w_ = _PRIVATE.truncatef32(w);
9999
}
100100

101-
/**
102-
* Construct a new instance of float32x4 number with 0.0 in all lanes.
103-
* @constructor
104-
*/
105-
SIMD.float32x4.zero = function() {
106-
return SIMD.float32x4(0.0, 0.0, 0.0, 0.0);
107-
}
108-
109101
/**
110102
* Construct a new instance of float32x4 number with the same value
111103
* in all lanes.
@@ -185,14 +177,6 @@ SIMD.float64x2 = function(x, y) {
185177
this.y_ = +y;
186178
}
187179

188-
/**
189-
* Construct a new instance of float64x2 number with 0.0 in all lanes.
190-
* @constructor
191-
*/
192-
SIMD.float64x2.zero = function() {
193-
return SIMD.float64x2(0.0, 0.0);
194-
}
195-
196180
/**
197181
* Construct a new instance of float64x2 number with the same value
198182
* in all lanes.
@@ -271,14 +255,6 @@ SIMD.int32x4 = function(x, y, z, w) {
271255
this.w_ = w|0;
272256
}
273257

274-
/**
275-
* Construct a new instance of int32x4 number with 0 in all lanes.
276-
* @constructor
277-
*/
278-
SIMD.int32x4.zero = function() {
279-
return SIMD.int32x4(0, 0, 0, 0);
280-
}
281-
282258
/**
283259
* Construct a new instance of int32x4 number with 0xFFFFFFFF or 0x0 in each
284260
* lane, depending on the truth value in x, y, z, and w.
@@ -498,16 +474,6 @@ SIMD.float32x4.reciprocalSqrt = function(t) {
498474
Math.sqrt(1.0 / t.z), Math.sqrt(1.0 / t.w));
499475
}
500476

501-
/**
502-
* @return {float32x4} New instance of float32x4 with values of t
503-
* scaled by s.
504-
*/
505-
SIMD.float32x4.scale = function(t, s) {
506-
checkFloat32x4(t);
507-
var s4 = SIMD.float32x4.splat(s);
508-
return SIMD.float32x4.mul(t,s4);
509-
}
510-
511477
/**
512478
* @return {float32x4} New instance of float32x4 with square root of
513479
* values of t.
@@ -1117,15 +1083,6 @@ SIMD.float64x2.reciprocalSqrt = function(t) {
11171083
return SIMD.float64x2(Math.sqrt(1.0 / t.x), Math.sqrt(1.0 / t.y));
11181084
}
11191085

1120-
/**
1121-
* @return {float64x2} New instance of float32x4 with values of t
1122-
* scaled by s.
1123-
*/
1124-
SIMD.float64x2.scale = function(t, s) {
1125-
checkFloat64x2(t);
1126-
return SIMD.float64x2(s * t.x, s * t.y);
1127-
}
1128-
11291086
/**
11301087
* @return {float64x2} New instance of float32x4 with square root of
11311088
* values of t.
@@ -1583,54 +1540,6 @@ SIMD.int32x4.withW = function(t, w) {
15831540
return SIMD.int32x4(t.x, t.y, t.z, w);
15841541
}
15851542

1586-
/**
1587-
* @param {int32x4} t An instance of int32x4.
1588-
* @param {boolean} x flag used for x lane.
1589-
* @return {int32x4} New instance of int32x4 with the values in t and
1590-
* x lane replaced with {x}.
1591-
*/
1592-
SIMD.int32x4.withFlagX = function(t, flagX) {
1593-
checkInt32x4(t);
1594-
var x = flagX ? 0xFFFFFFFF : 0x0;
1595-
return SIMD.int32x4(x, t.y, t.z, t.w);
1596-
}
1597-
1598-
/**
1599-
* @param {int32x4} t An instance of int32x4.
1600-
* @param {boolean} y flag used for y lane.
1601-
* @return {int32x4} New instance of int32x4 with the values in t and
1602-
* y lane replaced with {y}.
1603-
*/
1604-
SIMD.int32x4.withFlagY = function(t, flagY) {
1605-
checkInt32x4(t);
1606-
var y = flagY ? 0xFFFFFFFF : 0x0;
1607-
return SIMD.int32x4(t.x, y, t.z, t.w);
1608-
}
1609-
1610-
/**
1611-
* @param {int32x4} t An instance of int32x4.
1612-
* @param {boolean} z flag used for z lane.
1613-
* @return {int32x4} New instance of int32x4 with the values in t and
1614-
* z lane replaced with {z}.
1615-
*/
1616-
SIMD.int32x4.withFlagZ = function(t, flagZ) {
1617-
checkInt32x4(t);
1618-
var z = flagZ ? 0xFFFFFFFF : 0x0;
1619-
return SIMD.int32x4(t.x, t.y, z, t.w);
1620-
}
1621-
1622-
/**
1623-
* @param {int32x4} t An instance of int32x4.
1624-
* @param {boolean} w flag used for w lane.
1625-
* @return {int32x4} New instance of int32x4 with the values in t and
1626-
* w lane replaced with {w}.
1627-
*/
1628-
SIMD.int32x4.withFlagW = function(t, flagW) {
1629-
checkInt32x4(t);
1630-
var w = flagW ? 0xFFFFFFFF : 0x0;
1631-
return SIMD.int32x4(t.x, t.y, t.z, w);
1632-
}
1633-
16341543
/**
16351544
* @param {int32x4} t An instance of int32x4.
16361545
* @param {int32x4} other An instance of int32x4.

src/ecmascript_simd_tests.js

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,6 @@ test('float32x4 reciprocal sqrt', function() {
390390
almostEqual(4.0, c.w);
391391
});
392392

393-
test('float32x4 scale', function() {
394-
var a = SIMD.float32x4(8.0, 4.0, 2.0, -2.0);
395-
var c = SIMD.float32x4.scale(a, 0.5);
396-
equal(4.0, c.x);
397-
equal(2.0, c.y);
398-
equal(1.0, c.z);
399-
equal(-1.0, c.w);
400-
});
401-
402393
test('float32x4 sqrt', function() {
403394
var a = SIMD.float32x4(16.0, 9.0, 4.0, 1.0);
404395
var c = SIMD.float32x4.sqrt(a);
@@ -1155,13 +1146,6 @@ test('float64x2 splat constructor', function() {
11551146
equal(m.x, m.y);
11561147
});
11571148

1158-
test('float64x2 zero constructor', function() {
1159-
equal('function', typeof SIMD.float64x2.zero);
1160-
var m = SIMD.float64x2.zero();
1161-
equal(0.0, m.x);
1162-
equal(0.0, m.y);
1163-
});
1164-
11651149
test('float64x2 fromFloat32x4 constructor', function() {
11661150
var m = SIMD.float32x4(1.0, 2.0, 3.0, 4.0);
11671151
var n = SIMD.float64x2.fromFloat32x4(m);
@@ -1461,13 +1445,6 @@ test('float64x2 reciprocal sqrt', function() {
14611445
almostEqual(2.0, c.y);
14621446
});
14631447

1464-
test('float64x2 scale', function() {
1465-
var a = SIMD.float64x2(8.0, -2.0);
1466-
var c = SIMD.float64x2.scale(a, 0.5);
1467-
equal(4.0, c.x);
1468-
equal(-1.0, c.y);
1469-
});
1470-
14711448
test('float64x2 sqrt', function() {
14721449
var a = SIMD.float64x2(16.0, 9.0);
14731450
var c = SIMD.float64x2.sqrt(a);
@@ -1949,79 +1926,6 @@ test('int32x4 withW', function() {
19491926
equal(20, c.w);
19501927
});
19511928

1952-
test('int32x4 withFlagX', function() {
1953-
var a = SIMD.int32x4.bool(true, false, true, false);
1954-
var c = SIMD.int32x4.withFlagX(a, true);
1955-
equal(true, c.flagX);
1956-
equal(false, c.flagY);
1957-
equal(true, c.flagZ);
1958-
equal(false, c.flagW);
1959-
c = SIMD.int32x4.withFlagX(a, false);
1960-
equal(false, c.flagX);
1961-
equal(false, c.flagY);
1962-
equal(true, c.flagZ);
1963-
equal(false, c.flagW);
1964-
equal(0x0, c.x);
1965-
equal(0x0, c.y);
1966-
equal(-1, c.z);
1967-
equal(0x0, c.w);
1968-
});
1969-
1970-
test('int32x4 withFlagY', function() {
1971-
var a = SIMD.int32x4.bool(true, false, true, false);
1972-
var c = SIMD.int32x4.withFlagY(a, true);
1973-
equal(true, c.flagX);
1974-
equal(true, c.flagY);
1975-
equal(true, c.flagZ);
1976-
equal(false, c.flagW);
1977-
c = SIMD.int32x4.withFlagY(a, false);
1978-
equal(true, c.flagX);
1979-
equal(false, c.flagY);
1980-
equal(true, c.flagZ);
1981-
equal(false, c.flagW);
1982-
equal(-1, c.x);
1983-
equal(0x0, c.y);
1984-
equal(-1, c.z);
1985-
equal(0x0, c.w);
1986-
});
1987-
1988-
test('int32x4 withFlagZ', function() {
1989-
var a = SIMD.int32x4.bool(true, false, true, false);
1990-
var c = SIMD.int32x4.withFlagZ(a, true);
1991-
equal(-1, c.x);
1992-
equal(true, c.flagX);
1993-
equal(false, c.flagY);
1994-
equal(true, c.flagZ);
1995-
equal(false, c.flagW);
1996-
c = SIMD.int32x4.withFlagZ(a, false);
1997-
equal(true, c.flagX);
1998-
equal(false, c.flagY);
1999-
equal(false, c.flagZ);
2000-
equal(false, c.flagW);
2001-
equal(-1, c.x);
2002-
equal(0x0, c.y);
2003-
equal(0x0, c.z);
2004-
equal(0x0, c.w);
2005-
});
2006-
2007-
test('int32x4 withFlagW', function() {
2008-
var a = SIMD.int32x4.bool(true, false, true, false);
2009-
var c = SIMD.int32x4.withFlagW(a, true);
2010-
equal(true, c.flagX);
2011-
equal(false, c.flagY);
2012-
equal(true, c.flagZ);
2013-
equal(true, c.flagW);
2014-
c = SIMD.int32x4.withFlagW(a, false);
2015-
equal(true, c.flagX);
2016-
equal(false, c.flagY);
2017-
equal(true, c.flagZ);
2018-
equal(false, c.flagW);
2019-
equal(-1, c.x);
2020-
equal(0x0, c.y);
2021-
equal(-1, c.z);
2022-
equal(0x0, c.w);
2023-
});
2024-
20251929
test('int32x4 and', function() {
20261930
var m = SIMD.int32x4(0xAAAAAAAA, 0xAAAAAAAA, -1431655766, 0xAAAAAAAA);
20271931
var n = SIMD.int32x4(0x55555555, 0x55555555, 0x55555555, 0x55555555);

0 commit comments

Comments
 (0)