Bug 1155211: Remove selectBits on Float types; r=nbp

--HG--
extra : rebase_source : d78859d4900403c74c3dc25bca70a98ae55d2f23
extra : histedit_source : e135f9d93e9d40d9107e50a19ff66d700be9379f
This commit is contained in:
Benjamin Bouvier 2015-07-06 12:41:14 +02:00
Родитель 44f39fa226
Коммит 995104a40e
5 изменённых файлов: 17 добавлений и 94 удалений

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

@ -64,7 +64,6 @@
V(clamp, Clamp<Float32x4>, 3) \
V(replaceLane, (ReplaceLane<Float32x4>), 3) \
V(select, (Select<Float32x4, Int32x4>), 3) \
V(selectBits, (SelectBits<Float32x4, Int32x4>), 3) \
V(store, (Store<Float32x4, 4>), 3) \
V(store3, (Store<Float32x4, 3>), 3) \
V(store2, (Store<Float32x4, 2>), 3) \
@ -118,7 +117,6 @@
V(clamp, Clamp<Float64x2>, 3) \
V(replaceLane, (ReplaceLane<Float64x2>), 3) \
V(select, (Select<Float64x2, Int32x4>), 3) \
V(selectBits, (SelectBits<Float64x2, Int32x4>), 3) \
V(store, (Store<Float64x2, 2>), 3) \
V(store1, (Store<Float64x2, 1>), 3)
@ -292,6 +290,7 @@
_(fromFloat32x4Bits)
#define FOREACH_INT32X4_SIMD_OP(_) \
CONVERSION_INT32X4_SIMD_OP(_) \
_(selectBits) \
_(shiftLeftByScalar) \
_(shiftRightArithmeticByScalar) \
_(shiftRightLogicalByScalar)
@ -333,7 +332,6 @@
_(extractLane) \
_(replaceLane) \
_(select) \
_(selectBits) \
_(splat) \
_(not) \
_(neg) \

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

@ -2,23 +2,12 @@ load(libdir + 'simd.js');
setJitCompilerOption("ion.warmup.trigger", 50);
function Int32x4FromTypeBits(type, vec) {
if (type == SIMD.Int32x4)
return vec;
if (type == SIMD.Float32x4)
return SIMD.Int32x4.fromFloat32x4Bits(vec);
throw 'unimplemented';
}
function selectBits(type, mask, ifTrue, ifFalse) {
function selectBits(mask, ifTrue, ifFalse) {
var Int32x4 = SIMD.Int32x4;
var tv = Int32x4FromTypeBits(type, ifTrue);
var fv = Int32x4FromTypeBits(type, ifFalse);
var tr = Int32x4.and(mask, tv);
var fr = Int32x4.and(Int32x4.not(mask), fv);
var tr = Int32x4.and(mask, ifTrue);
var fr = Int32x4.and(Int32x4.not(mask), ifFalse);
var orApplied = Int32x4.or(tr, fr);
var converted = type == Int32x4 ? orApplied : type.fromInt32x4Bits(orApplied);
return simdToArray(converted);
return simdToArray(orApplied);
}
function select(type, mask, ifTrue, ifFalse) {
@ -45,11 +34,11 @@ function f() {
for (var i = 0; i < 150; i++) {
assertEqX4(SIMD.Float32x4.select(TTFT, f1, f2), select(SIMD.Float32x4, TTFT, f1, f2));
assertEqX4(SIMD.Float32x4.select(TFTF, f1, f2), select(SIMD.Float32x4, TFTF, f1, f2));
assertEqX4(SIMD.Int32x4.select(TFTF, i1, i2), select(SIMD.Int32x4, TFTF, i1, i2));
assertEqX4(SIMD.Int32x4.select(TTFT, i1, i2), select(SIMD.Int32x4, TTFT, i1, i2));
assertEqX4(SIMD.Float32x4.selectBits(mask, f1, f2), selectBits(SIMD.Float32x4, mask, f1, f2));
assertEqX4(SIMD.Int32x4.selectBits(mask, i1, i2), selectBits(SIMD.Int32x4, mask, i1, i2));
assertEqX4(SIMD.Int32x4.selectBits(mask, i1, i2), selectBits(mask, i1, i2));
}
}

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

@ -877,7 +877,6 @@ for (var i = 1; i < 64; i++) {
const I32SEL = 'var i4sel = i4.select;'
const F32SEL = 'var f4sel = f4.select;'
const I32BSEL = 'var i4sel = i4.selectBits;'
const F32BSEL = 'var f4sel = f4.selectBits;'
assertAsmTypeFail('glob', USE_ASM + I32 + F32 + CI32 + I32SEL + "function f() {var x=f4(1,2,3,4); return ci4(i4sel(x,x,x));} return f");
assertAsmTypeFail('glob', USE_ASM + I32 + F32 + CI32 + I32SEL + "function f() {var m=f4(1,2,3,4); var x=i4(1,2,3,4); return ci4(i4sel(m,x,x));} return f");
@ -920,11 +919,6 @@ assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + CI32 + I32BSEL + "function
assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + CI32 + I32BSEL + "function f() {var m=i4(0,0xffffffff,0,0xffffffff); var x=i4(1,2,3,4); var y=i4(5,6,7,8); return ci4(i4sel(m,x,y)); } return f"), this)(), [5, 2, 7, 4]);
assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + CI32 + I32BSEL + "function f() {var m=i4(0,0,0xffffffff,0xffffffff); var x=i4(1,2,3,4); var y=i4(5,6,7,8); return ci4(i4sel(m,x,y)); } return f"), this)(), [5, 6, 3, 4]);
assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + F32 + CF32 + F32BSEL + "function f() {var m=i4(0,0,0,0); var x=f4(1,2,3,4); var y=f4(5,6,7,8); return cf4(f4sel(m,x,y)); } return f"), this)(), [5, 6, 7, 8]);
assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + F32 + CF32 + F32BSEL + "function f() {var m=i4(0xffffffff,0xffffffff,0xffffffff,0xffffffff); var x=f4(1,2,3,4); var y=f4(5,6,7,8); return cf4(f4sel(m,x,y)); } return f"), this)(), [1, 2, 3, 4]);
assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + F32 + CF32 + F32BSEL + "function f() {var m=i4(0,0xffffffff,0,0xffffffff); var x=f4(1,2,3,4); var y=f4(5,6,7,8); return cf4(f4sel(m,x,y)); } return f"), this)(), [5, 2, 7, 4]);
assertEqX4(asmLink(asmCompile('glob', USE_ASM + I32 + F32 + CF32 + F32BSEL + "function f() {var m=i4(0,0,0xffffffff,0xffffffff); var x=f4(1,2,3,4); var y=f4(5,6,7,8); return cf4(f4sel(m,x,y)); } return f"), this)(), [5, 6, 3, 4]);
// Specific selectBits tests
var masks = [
SIMD.Int32x4(1337, 0x1337, 0x42, 42),
@ -945,18 +939,6 @@ for (var mask of masks) {
}
}
inputs = [
[SIMD.Float32x4(0.125,4.25,9.75,16.125), SIMD.Float32x4(1.5,2.75,3.25,4.5)],
[SIMD.Float32x4(-1.5,-0,NaN,-Infinity), SIMD.Float32x4(1,-2,13.37,3.13)],
[SIMD.Float32x4(1.5,2.75,NaN,Infinity), SIMD.Float32x4(-NaN,-Infinity,9.75,16.125)]
];
var f32bsel = asmLink(asmCompile('glob', USE_ASM + I32 + F32 + CI32 + CF32 + F32BSEL + "function f(mask, ifTrue, ifFalse) {mask=ci4(mask); ifTrue=cf4(ifTrue); ifFalse=cf4(ifFalse); return cf4(f4sel(mask,ifTrue,ifFalse)); } return f"), this)
for (var mask of masks)
for (var [x, y] of inputs)
assertEqX4(f32bsel(mask, x, y), simdToArray(SIMD.Float32x4.selectBits(mask, x, y)));
// Splat
const I32SPLAT = 'var splat=i4.splat;'
const F32SPLAT = 'var splat=f4.splat;'

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

@ -368,8 +368,6 @@ IonBuilder::inlineNativeCall(CallInfo& callInfo, JSFunction* target)
return inlineSimdSelect(callInfo, native, IsElementWise(false), SimdTypeDescr::Int32x4);
if (native == js::simd_float32x4_select)
return inlineSimdSelect(callInfo, native, IsElementWise(true), SimdTypeDescr::Float32x4);
if (native == js::simd_float32x4_selectBits)
return inlineSimdSelect(callInfo, native, IsElementWise(false), SimdTypeDescr::Float32x4);
if (native == js::simd_int32x4_swizzle)
return inlineSimdShuffle(callInfo, native, SimdTypeDescr::Int32x4, 1, 4);

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

@ -24,12 +24,6 @@ function getMask(i, maskLength) {
throw new Error("Invalid mask length.");
}
function selectMaskType(type) {
if (type == Int32x4 || type == Float32x4 || type == Float64x2)
return Int32x4;
return type;
}
function select(mask, ifTrue, ifFalse) {
var m = simdToArray(mask);
var tv = simdToArray(ifTrue);
@ -57,43 +51,11 @@ function testSelect(type, inputs) {
}
}
function intFromTypeBits(type, vec) {
switch (type) {
case Float32x4:
return Int32x4.fromFloat32x4Bits(vec);
case Float64x2:
return Int32x4.fromFloat64x2Bits(vec);
case Int8x16:
return vec;
case Int16x8:
return vec;
case Int32x4:
return vec;
default:
throw new TypeError("Unknown SIMD type.");
}
}
function selectBits(type, mask, ifTrue, ifFalse) {
var maskType = selectMaskType(type);
var tv = intFromTypeBits(type, ifTrue);
var fv = intFromTypeBits(type, ifFalse);
var tr = maskType.and(mask, tv);
var fr = maskType.and(maskType.not(mask), fv);
var orApplied = maskType.or(tr, fr);
var converted = type == maskType ? orApplied : type.fromInt32x4Bits(orApplied);
return simdToArray(converted);
}
function findCorrespondingScalarTypedArray(type) {
switch (type) {
case Int8x16: return Int8Array;
case Int16x8: return Int16Array;
case Int32x4: return Int32Array;
case Float32x4: return Float32Array;
case Float64x2: return Float64Array;
default: throw new Error("undefined scalar typed array");
}
var tr = type.and(mask, ifTrue);
var fr = type.and(type.not(mask), ifFalse);
var orApplied = type.or(tr, fr);
return simdToArray(orApplied);
}
/**
@ -103,12 +65,11 @@ function findCorrespondingScalarTypedArray(type) {
function testSelectBitsSimple(type, inputs) {
var x, y;
var maskLength = simdLengthType(type);
maskLength = maskLength != 2 ? maskLength : 4;
var ScalarTypedArray = findCorrespondingScalarTypedArray(type);
for (var i = 0; i < Math.pow(maskLength, 2); i++) {
var mask = getMask(i, maskLength);
for ([x, y] of inputs)
assertEqVec(type.selectBits(mask, x, y), selectBits(type, mask, x, y));
assertEqVec(type.selectBits(mask, x, y), simdToArray(type.select(mask, x, y)));
}
}
@ -129,19 +90,18 @@ function testSelectBitsComplex(type, inputs) {
Int32x4(0x00FF1CE, 0xBAADF00D, 0xDEADBEEF, 0xCAFED00D),
Int32x4(0xD15EA5E, 0xDEADC0DE, 0xFACEB00C, 0x4B1D4B1D)
];
var masks = [];
var maskType = selectMaskType(type);
if (maskType == SIMD.Int8x16)
var masks;
if (type == SIMD.Int8x16)
masks = masks8;
else if (maskType == SIMD.Int16x8)
else if (type == SIMD.Int16x8)
masks = masks16;
else if (maskType == SIMD.Int32x4)
else if (type == SIMD.Int32x4)
masks = masks32;
else
throw new Error("Unknown mask type.");
var x, y;
var ScalarTypedArray = findCorrespondingScalarTypedArray(type);
for (var mask of masks) {
for ([x, y] of inputs)
assertEqVec(type.selectBits(mask, x, y), selectBits(type, mask, x, y));
@ -185,8 +145,6 @@ function test() {
];
testSelect(Float32x4, inputs);
testSelectBitsSimple(Float32x4, inputs);
testSelectBitsComplex(Float32x4, inputs);
inputs = [
[Float64x2(0.125,4.25), Float64x2(9.75,16.125)],
@ -198,8 +156,6 @@ function test() {
];
testSelect(Float64x2, inputs);
testSelectBitsSimple(Float64x2, inputs);
testSelectBitsComplex(Float64x2, inputs);
if (typeof reportCompare === "function")
reportCompare(true, true);