summaryrefslogtreecommitdiff
path: root/compiler/optimizing/nodes_vector.h
diff options
context:
space:
mode:
author Aart Bik <ajcbik@google.com> 2017-10-19 14:40:55 -0700
committer Aart Bik <ajcbik@google.com> 2017-10-20 11:10:52 -0700
commit4d1a9d4b01ef0bbea3b7dfa9f31420d6e1d0ac83 (patch)
treedd60bed0d302987c2a8f766d58fc855f510183c5 /compiler/optimizing/nodes_vector.h
parent758aeab86b79369f9dfc6ae5d3bd98232f5b9c40 (diff)
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
Diffstat (limited to 'compiler/optimizing/nodes_vector.h')
-rw-r--r--compiler/optimizing/nodes_vector.h16
1 files changed, 16 insertions, 0 deletions
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);
}