ART: Remove InstructionTypeEquals().
Avoid the virtual call and simply compare the instruction
kinds.
Test: Rely on TreeHugger.
Change-Id: I7310de976614c5ec63d61a447a40047de5bc654d
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 0fe1672..ca84d42 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -2666,10 +2666,10 @@
HConstant* const2;
HBinaryOperation* y;
- if (instruction->InstructionTypeEquals(left) && right->IsConstant()) {
+ if (instruction->GetKind() == left->GetKind() && right->IsConstant()) {
const2 = right->AsConstant();
y = left->AsBinaryOperation();
- } else if (left->IsConstant() && instruction->InstructionTypeEquals(right)) {
+ } else if (left->IsConstant() && instruction->GetKind() == right->GetKind()) {
const2 = left->AsConstant();
y = right->AsBinaryOperation();
} else {
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index f784f8f..6029347 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -1680,10 +1680,9 @@
}
bool HInstruction::Equals(const HInstruction* other) const {
- if (!InstructionTypeEquals(other)) return false;
- DCHECK_EQ(GetKind(), other->GetKind());
- if (!InstructionDataEquals(other)) return false;
+ if (GetKind() != other->GetKind()) return false;
if (GetType() != other->GetType()) return false;
+ if (!InstructionDataEquals(other)) return false;
HConstInputsRef inputs = GetInputs();
HConstInputsRef other_inputs = other->GetInputs();
if (inputs.size() != other_inputs.size()) return false;
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 295f570..3433e91 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -1525,9 +1525,6 @@
H##type& operator=(const H##type&) = delete; \
public: \
const char* DebugName() const OVERRIDE { return #type; } \
- bool InstructionTypeEquals(const HInstruction* other) const OVERRIDE { \
- return other->Is##type(); \
- } \
HInstruction* Clone(ArenaAllocator* arena) const OVERRIDE { \
DCHECK(IsClonable()); \
return new (arena) H##type(*this->As##type()); \
@@ -2272,11 +2269,6 @@
// meanings? split and rename?
virtual bool CanBeMoved() const { return false; }
- // Returns whether the two instructions are of the same kind.
- virtual bool InstructionTypeEquals(const HInstruction* other ATTRIBUTE_UNUSED) const {
- return false;
- }
-
// Returns whether any data encoded in the two instructions is equal.
// This method does not look at the inputs. Both instructions must be
// of the same type, otherwise the method has undefined behavior.