From 4d1a9d4b01ef0bbea3b7dfa9f31420d6e1d0ac83 Mon Sep 17 00:00:00 2001 From: Aart Bik Date: Thu, 19 Oct 2017 14:40:55 -0700 Subject: Improve sign and zero extension analysis. Rationale: This was needed to fix the regression introduced by a prior type based cl. With the new type system ramping up, however, this is actually more simplification (remove the And recognition for example) than new code! Test: test-art-host test-art-target Bug: 67935418 Change-Id: I4284f8f29f3d26e4033a3014d0c697677cc0d795 --- compiler/optimizing/nodes_vector.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'compiler/optimizing/nodes_vector.h') diff --git a/compiler/optimizing/nodes_vector.h b/compiler/optimizing/nodes_vector.h index 4e78e4e6a2..17540b9770 100644 --- a/compiler/optimizing/nodes_vector.h +++ b/compiler/optimizing/nodes_vector.h @@ -136,6 +136,20 @@ class HVecOperation : public HVariableInputSizeInstruction { } } + // Maps an integral type to the same-size unsigned type and leaves other types alone. + static DataType::Type ToUnsignedType(DataType::Type type) { + switch (type) { + case DataType::Type::kBool: // 1-byte storage unit + case DataType::Type::kInt8: + return DataType::Type::kUint8; + case DataType::Type::kInt16: + return DataType::Type::kUint16; + default: + DCHECK(type != DataType::Type::kVoid && type != DataType::Type::kReference) << type; + return type; + } + } + DECLARE_ABSTRACT_INSTRUCTION(VecOperation); protected: @@ -254,6 +268,8 @@ inline static bool HasConsistentPackedTypes(HInstruction* input, DataType::Type } DCHECK(input->IsVecOperation()); DataType::Type input_type = input->AsVecOperation()->GetPackedType(); + DCHECK_EQ(HVecOperation::ToUnsignedType(input_type) == HVecOperation::ToUnsignedType(type), + HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type)); return HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type); } -- cgit v1.2.3-59-g8ed1b