diff options
author | 2018-05-03 17:09:09 +0100 | |
---|---|---|
committer | 2018-05-08 11:36:11 +0100 | |
commit | bd78567cef305e35481734b7fc24f68ded031439 (patch) | |
tree | e3873b73e3631c5cd70c1a3f8f38e79dad25d890 /compiler/optimizing/nodes_vector.h | |
parent | 9926e4615d75cb6c9371e1766a14b0a80089ae18 (diff) |
Store HIR type in HInstruction::packed_field_.
This is similar to
https://android-review.googlesource.com/609566
though the performance impact has not been measured.
However, avoiding a virtual call reduces pressure on the
branch predictor and provides better optimization
opportunities for the C++ compiler.
As there is now no difference between HTemplateInstruction<>
and HExpression<> (the type is stored in HInstruction), we
remove the former and use HExpression<> for all instructions
that have a fixed number of inputs.
Test: Rely on TreeHugger.
Change-Id: Ib3fd111048b0ac38ee65386a7e5af70c5ccc98de
Diffstat (limited to 'compiler/optimizing/nodes_vector.h')
-rw-r--r-- | compiler/optimizing/nodes_vector.h | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/compiler/optimizing/nodes_vector.h b/compiler/optimizing/nodes_vector.h index 1a484e1944..c5e9a8d036 100644 --- a/compiler/optimizing/nodes_vector.h +++ b/compiler/optimizing/nodes_vector.h @@ -79,13 +79,14 @@ class HVecOperation : public HVariableInputSizeInstruction { size_t vector_length, uint32_t dex_pc) : HVariableInputSizeInstruction(kind, + kSIMDType, side_effects, dex_pc, allocator, number_of_inputs, kArenaAllocVectorNode), vector_length_(vector_length) { - SetPackedField<TypeField>(packed_type); + SetPackedField<PackedTypeField>(packed_type); DCHECK_LT(1u, vector_length); } @@ -99,14 +100,9 @@ class HVecOperation : public HVariableInputSizeInstruction { return vector_length_ * DataType::Size(GetPackedType()); } - // Returns the type of the vector operation. - DataType::Type GetType() const OVERRIDE { - return kSIMDType; - } - // Returns the true component type packed in a vector. DataType::Type GetPackedType() const { - return GetPackedField<TypeField>(); + return GetPackedField<PackedTypeField>(); } // Assumes vector nodes cannot be moved by default. Each concrete implementation @@ -185,12 +181,12 @@ class HVecOperation : public HVariableInputSizeInstruction { protected: // Additional packed bits. - static constexpr size_t kFieldType = HInstruction::kNumberOfGenericPackedBits; - static constexpr size_t kFieldTypeSize = + static constexpr size_t kFieldPackedType = HInstruction::kNumberOfGenericPackedBits; + static constexpr size_t kFieldPackedTypeSize = MinimumBitsToStore(static_cast<size_t>(DataType::Type::kLast)); - static constexpr size_t kNumberOfVectorOpPackedBits = kFieldType + kFieldTypeSize; + static constexpr size_t kNumberOfVectorOpPackedBits = kFieldPackedType + kFieldPackedTypeSize; static_assert(kNumberOfVectorOpPackedBits <= kMaxNumberOfPackedBits, "Too many packed fields."); - using TypeField = BitField<DataType::Type, kFieldType, kFieldTypeSize>; + using PackedTypeField = BitField<DataType::Type, kFieldPackedType, kFieldPackedTypeSize>; DEFAULT_COPY_CONSTRUCTOR(VecOperation); @@ -358,11 +354,9 @@ class HVecExtractScalar FINAL : public HVecUnaryOperation { DCHECK(HasConsistentPackedTypes(input, packed_type)); DCHECK_LT(index, vector_length); DCHECK_EQ(index, 0u); - } - - // Yields a single component in the vector. - DataType::Type GetType() const OVERRIDE { - return GetPackedType(); + // Yields a single component in the vector. + // Overrides the kSIMDType set by the VecOperation constructor. + SetPackedField<TypeField>(packed_type); } // An extract needs to stay in place, since SIMD registers are not |