mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1025475: SIMD: Fold SIMD created values into SimdConstants; r=sunfish
This commit is contained in:
parent
62d25f8b05
commit
48ef37ca1b
@ -588,6 +588,39 @@ MConstant::canProduceFloat32() const
|
||||
return true;
|
||||
}
|
||||
|
||||
MDefinition*
|
||||
MSimdValueX4::foldsTo(TempAllocator &alloc)
|
||||
{
|
||||
DebugOnly<MIRType> scalarType = SimdTypeToScalarType(type());
|
||||
for (size_t i = 0; i < 4; ++i) {
|
||||
MDefinition *op = getOperand(i);
|
||||
if (!op->isConstant())
|
||||
return this;
|
||||
JS_ASSERT(op->type() == scalarType);
|
||||
}
|
||||
|
||||
SimdConstant cst;
|
||||
switch (type()) {
|
||||
case MIRType_Int32x4: {
|
||||
int32_t a[4];
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
a[i] = getOperand(i)->toConstant()->value().toInt32();
|
||||
cst = SimdConstant::CreateX4(a);
|
||||
break;
|
||||
}
|
||||
case MIRType_Float32x4: {
|
||||
float a[4];
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
a[i] = getOperand(i)->toConstant()->value().toNumber();
|
||||
cst = SimdConstant::CreateX4(a);
|
||||
break;
|
||||
}
|
||||
default: MOZ_ASSUME_UNREACHABLE("unexpected type in MSimdValueX4::foldsTo");
|
||||
}
|
||||
|
||||
return MSimdConstant::New(alloc, cst, type());
|
||||
}
|
||||
|
||||
MCloneLiteral *
|
||||
MCloneLiteral::New(TempAllocator &alloc, MDefinition *obj)
|
||||
{
|
||||
|
@ -1268,6 +1268,8 @@ class MSimdValueX4 : public MQuaternaryInstruction
|
||||
bool congruentTo(const MDefinition *ins) const {
|
||||
return congruentIfOperandsEqual(ins);
|
||||
}
|
||||
|
||||
MDefinition *foldsTo(TempAllocator &alloc);
|
||||
};
|
||||
|
||||
// A constant SIMD value.
|
||||
|
Loading…
Reference in New Issue
Block a user