From bd78567cef305e35481734b7fc24f68ded031439 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 3 May 2018 17:09:09 +0100 Subject: 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 --- compiler/optimizing/nodes_vector.h | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'compiler/optimizing/nodes_vector.h') 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(packed_type); + SetPackedField(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(); + return GetPackedField(); } // 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(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; + using PackedTypeField = BitField; 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(packed_type); } // An extract needs to stay in place, since SIMD registers are not -- cgit v1.2.3-59-g8ed1b