Bug 1225908 - SimdTypeToLaneType. r=bbouvier
authorJakob Stoklund Olesen <jolesen@mozilla.com>
Thu, 19 Nov 2015 10:37:18 -0800
changeset 273396 94d80c1508bfed035b52d5564d81138d3657431d
parent 273395 e7fa9a0b61f69e6f61d0e22298ddf3848620e997
child 273397 1e9a544bc43ebc07fdacf5736ae8936a4ba3bf95
push id29702
push usercbook@mozilla.com
push dateFri, 20 Nov 2015 12:13:22 +0000
treeherdermozilla-central@ec628289d8b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1225908
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1225908 - SimdTypeToLaneType. r=bbouvier Rename the function SimdTypeToScalarType to SimdTypeToLaneType. Since we also have Scalar::Type, it is best to use the term 'lane' to refer to the parts of a vector.
js/src/jit/IonTypes.h
js/src/jit/MCallOptimize.cpp
js/src/jit/MIR.cpp
js/src/jit/MIR.h
js/src/jit/TypePolicy.cpp
--- a/js/src/jit/IonTypes.h
+++ b/js/src/jit/IonTypes.h
@@ -639,18 +639,20 @@ ScalarTypeToLength(Scalar::Type type)
       case Scalar::Int32x4:
         return 4;
       case Scalar::MaxTypedArrayViewType:
         break;
     }
     MOZ_CRASH("unexpected SIMD kind");
 }
 
+// Get the type of the individual lanes in a SIMD type.
+// For example, Int32x4 -> Int32, FLoat32x4 -> Float32 etc.
 static inline MIRType
-SimdTypeToScalarType(MIRType type)
+SimdTypeToLaneType(MIRType type)
 {
     MOZ_ASSERT(IsSimdType(type));
     static_assert(MIRType_Last <= ELEMENT_TYPE_MASK,
                   "ELEMENT_TYPE_MASK should be larger than the last MIRType");
     return MIRType((type >> ELEMENT_TYPE_SHIFT) & ELEMENT_TYPE_MASK);
 }
 
 // Indicates a lane in a SIMD register: X for the first lane, Y for the second,
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -3229,23 +3229,23 @@ IonBuilder::inlineConstructSimdObject(Ca
     // allocate a templateObject in Baseline.
     InlineTypedObject* inlineTypedObject = &templateObject->as<InlineTypedObject>();
     MOZ_ASSERT(&inlineTypedObject->typeDescr() == descr);
 
     // When there are missing arguments, provide a default value
     // containing the coercion of 'undefined' to the right type.
     MConstant* defVal = nullptr;
     if (callInfo.argc() < SimdTypeToLength(simdType)) {
-        MIRType scalarType = SimdTypeToScalarType(simdType);
-        if (scalarType == MIRType_Int32) {
+        MIRType laneType = SimdTypeToLaneType(simdType);
+        if (laneType == MIRType_Int32) {
             defVal = constant(Int32Value(0));
         } else {
-            MOZ_ASSERT(IsFloatingPointType(scalarType));
+            MOZ_ASSERT(IsFloatingPointType(laneType));
             defVal = constant(DoubleNaNValue());
-            defVal->setResultType(scalarType);
+            defVal->setResultType(laneType);
         }
     }
 
     MSimdValueX4* values =
         MSimdValueX4::New(alloc(), simdType,
                           callInfo.getArgWithDefault(0, defVal), callInfo.getArgWithDefault(1, defVal),
                           callInfo.getArgWithDefault(2, defVal), callInfo.getArgWithDefault(3, defVal));
     current->add(values);
@@ -3364,19 +3364,19 @@ IonBuilder::inlineSimdExtractLane(CallIn
     if (!arg->isConstantValue() || arg->type() != MIRType_Int32)
         return InliningStatus_NotInlined;
     int32_t lane = callInfo.getArg(1)->constantValue().toInt32();
     if (lane < 0 || lane >= 4)
         return InliningStatus_NotInlined;
 
     // See comment in inlineBinarySimd
     MIRType vecType = SimdTypeDescrToMIRType(type);
-    MIRType scalarType = SimdTypeToScalarType(vecType);
+    MIRType laneType = SimdTypeToLaneType(vecType);
     MSimdExtractElement* ins = MSimdExtractElement::New(alloc(), callInfo.getArg(0),
-                                                        vecType, scalarType, SimdLane(lane));
+                                                        vecType, laneType, SimdLane(lane));
     current->add(ins);
     current->push(ins);
     callInfo.setImplicitlyUsedUnchecked();
     return InliningStatus_Inlined;
 }
 
 IonBuilder::InliningStatus
 IonBuilder::inlineSimdReplaceLane(CallInfo& callInfo, JSNative native, SimdTypeDescr::Type type)
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -901,23 +901,23 @@ MConstant::canProduceFloat32() const
     if (type() == MIRType_Double)
         return IsFloat32Representable(value_.toDouble());
     return true;
 }
 
 MDefinition*
 MSimdValueX4::foldsTo(TempAllocator& alloc)
 {
-    DebugOnly<MIRType> scalarType = SimdTypeToScalarType(type());
+    DebugOnly<MIRType> laneType = SimdTypeToLaneType(type());
     bool allConstants = true;
     bool allSame = true;
 
     for (size_t i = 0; i < 4; ++i) {
         MDefinition* op = getOperand(i);
-        MOZ_ASSERT(op->type() == scalarType);
+        MOZ_ASSERT(op->type() == laneType);
         if (!op->isConstantValue())
             allConstants = false;
         if (i > 0 && op != getOperand(i - 1))
             allSame = false;
     }
 
     if (!allConstants && !allSame)
         return this;
@@ -947,21 +947,21 @@ MSimdValueX4::foldsTo(TempAllocator& all
 
     MOZ_ASSERT(allSame);
     return MSimdSplatX4::New(alloc, getOperand(0), type());
 }
 
 MDefinition*
 MSimdSplatX4::foldsTo(TempAllocator& alloc)
 {
-    DebugOnly<MIRType> scalarType = SimdTypeToScalarType(type());
+    DebugOnly<MIRType> laneType = SimdTypeToLaneType(type());
     MDefinition* op = getOperand(0);
     if (!op->isConstantValue())
         return this;
-    MOZ_ASSERT(op->type() == scalarType);
+    MOZ_ASSERT(op->type() == laneType);
 
     SimdConstant cst;
     switch (type()) {
       case MIRType_Int32x4: {
         int32_t a[4];
         int32_t v = getOperand(0)->constantValue().toInt32();
         for (size_t i = 0; i < 4; ++i)
             a[i] = v;
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -1396,26 +1396,26 @@ class MSimdValueX4
                              MDefinition* y, MDefinition* z, MDefinition* w)
     {
         return new(alloc) MSimdValueX4(type, x, y, z, w);
     }
 
     static MSimdValueX4* NewAsmJS(TempAllocator& alloc, MIRType type, MDefinition* x,
                                   MDefinition* y, MDefinition* z, MDefinition* w)
     {
-        mozilla::DebugOnly<MIRType> scalarType = SimdTypeToScalarType(type);
-        MOZ_ASSERT(scalarType == x->type());
-        MOZ_ASSERT(scalarType == y->type());
-        MOZ_ASSERT(scalarType == z->type());
-        MOZ_ASSERT(scalarType == w->type());
+        mozilla::DebugOnly<MIRType> laneType = SimdTypeToLaneType(type);
+        MOZ_ASSERT(laneType == x->type());
+        MOZ_ASSERT(laneType == y->type());
+        MOZ_ASSERT(laneType == z->type());
+        MOZ_ASSERT(laneType == w->type());
         return MSimdValueX4::New(alloc, type, x, y, z, w);
     }
 
     bool canConsumeFloat32(MUse* use) const override {
-        return SimdTypeToScalarType(type()) == MIRType_Float32;
+        return SimdTypeToLaneType(type()) == MIRType_Float32;
     }
 
     AliasSet getAliasSet() const override {
         return AliasSet::None();
     }
 
     bool congruentTo(const MDefinition* ins) const override {
         return congruentIfOperandsEqual(ins);
@@ -1440,27 +1440,27 @@ class MSimdSplatX4
         setResultType(type);
     }
 
   public:
     INSTRUCTION_HEADER(SimdSplatX4)
 
     static MSimdSplatX4* NewAsmJS(TempAllocator& alloc, MDefinition* v, MIRType type)
     {
-        MOZ_ASSERT(SimdTypeToScalarType(type) == v->type());
+        MOZ_ASSERT(SimdTypeToLaneType(type) == v->type());
         return new(alloc) MSimdSplatX4(type, v);
     }
 
     static MSimdSplatX4* New(TempAllocator& alloc, MDefinition* v, MIRType type)
     {
         return new(alloc) MSimdSplatX4(type, v);
     }
 
     bool canConsumeFloat32(MUse* use) const override {
-        return SimdTypeToScalarType(type()) == MIRType_Float32;
+        return SimdTypeToLaneType(type()) == MIRType_Float32;
     }
 
     AliasSet getAliasSet() const override {
         return AliasSet::None();
     }
 
     bool congruentTo(const MDefinition* ins) const override {
         return congruentIfOperandsEqual(ins);
@@ -1591,27 +1591,27 @@ class MSimdReinterpretCast
 // Extracts a lane element from a given vector type, given by its lane symbol.
 class MSimdExtractElement
   : public MUnaryInstruction,
     public SimdPolicy<0>::Data
 {
   protected:
     SimdLane lane_;
 
-    MSimdExtractElement(MDefinition* obj, MIRType vecType, MIRType scalarType, SimdLane lane)
+    MSimdExtractElement(MDefinition* obj, MIRType vecType, MIRType laneType, SimdLane lane)
       : MUnaryInstruction(obj), lane_(lane)
     {
         MOZ_ASSERT(IsSimdType(vecType));
         MOZ_ASSERT(uint32_t(lane) < SimdTypeToLength(vecType));
-        MOZ_ASSERT(!IsSimdType(scalarType));
-        MOZ_ASSERT(SimdTypeToScalarType(vecType) == scalarType);
+        MOZ_ASSERT(!IsSimdType(laneType));
+        MOZ_ASSERT(SimdTypeToLaneType(vecType) == laneType);
 
         setMovable();
         specialization_ = vecType;
-        setResultType(scalarType);
+        setResultType(laneType);
     }
 
   public:
     INSTRUCTION_HEADER(SimdExtractElement)
 
     static MSimdExtractElement* NewAsmJS(TempAllocator& alloc, MDefinition* obj, MIRType type,
                                          SimdLane lane)
     {
@@ -1660,17 +1660,17 @@ class MSimdInsertElement
 
   public:
     INSTRUCTION_HEADER(SimdInsertElement)
 
     static MSimdInsertElement* NewAsmJS(TempAllocator& alloc, MDefinition* vec, MDefinition* val,
                                          MIRType type, SimdLane lane)
     {
         MOZ_ASSERT(vec->type() == type);
-        MOZ_ASSERT(SimdTypeToScalarType(type) == val->type());
+        MOZ_ASSERT(SimdTypeToLaneType(type) == val->type());
         return new(alloc) MSimdInsertElement(vec, val, type, lane);
     }
 
     static MSimdInsertElement* New(TempAllocator& alloc, MDefinition* vec, MDefinition* val,
                                    MIRType type, SimdLane lane)
     {
         return new(alloc) MSimdInsertElement(vec, val, type, lane);
     }
@@ -1691,17 +1691,17 @@ class MSimdInsertElement
           case LaneY: return "lane y";
           case LaneZ: return "lane z";
           case LaneW: return "lane w";
         }
         MOZ_CRASH("unknown lane");
     }
 
     bool canConsumeFloat32(MUse* use) const override {
-        return use == getUseFor(1) && SimdTypeToScalarType(type()) == MIRType_Float32;
+        return use == getUseFor(1) && SimdTypeToLaneType(type()) == MIRType_Float32;
     }
 
     AliasSet getAliasSet() const override {
         return AliasSet::None();
     }
 
     bool congruentTo(const MDefinition* ins) const override {
         return binaryCongruentTo(ins) && lane_ == ins->toSimdInsertElement()->lane();
--- a/js/src/jit/TypePolicy.cpp
+++ b/js/src/jit/TypePolicy.cpp
@@ -562,27 +562,27 @@ NoFloatPolicyAfter<FirstOp>::adjustInput
 template bool NoFloatPolicyAfter<1>::adjustInputs(TempAllocator& alloc, MInstruction* def);
 template bool NoFloatPolicyAfter<2>::adjustInputs(TempAllocator& alloc, MInstruction* def);
 
 template <unsigned Op>
 bool
 SimdScalarPolicy<Op>::staticAdjustInputs(TempAllocator& alloc, MInstruction* ins)
 {
     MOZ_ASSERT(IsSimdType(ins->type()));
-    MIRType scalarType = SimdTypeToScalarType(ins->type());
+    MIRType laneType = SimdTypeToLaneType(ins->type());
 
     MDefinition* in = ins->getOperand(Op);
-    if (in->type() == scalarType)
+    if (in->type() == laneType)
         return true;
 
     MInstruction* replace;
-    if (scalarType == MIRType_Int32) {
+    if (laneType == MIRType_Int32) {
         replace = MTruncateToInt32::New(alloc, in);
     } else {
-        MOZ_ASSERT(scalarType == MIRType_Float32);
+        MOZ_ASSERT(laneType == MIRType_Float32);
         replace = MToFloat32::New(alloc, in);
     }
 
     ins->block()->insertBefore(ins, replace);
     ins->replaceOperand(Op, replace);
 
     return replace->typePolicy()->adjustInputs(alloc, replace);
 }