summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-12-01 14:16:20 +0000
committerNicolas Geoffray <ngeoffray@google.com>2014-12-01 14:38:56 +0000
commit01fcc9ee556f98d0163cc9b524e989760826926f (patch)
treedb932611fcfb1390c761ae589a99dee5e956c271 /compiler/optimizing/instruction_simplifier.cc
parentdff1069220465f93dc2e3636a0acd7522a5ba639 (diff)
downloadart-01fcc9ee556f98d0163cc9b524e989760826926f.zip
art-01fcc9ee556f98d0163cc9b524e989760826926f.tar.gz
art-01fcc9ee556f98d0163cc9b524e989760826926f.tar.bz2
Remove type conversion nodes converting to the same type.
When optimizing, we ensure these conversions do not reach the code generators. When not optimizing, we cannot get such situations. Change-Id: I717247c957667675dc261183019c88efa3a38452
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 3d65e9a..49ca443 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -26,6 +26,7 @@ class InstructionSimplifierVisitor : public HGraphVisitor {
void VisitSuspendCheck(HSuspendCheck* check) OVERRIDE;
void VisitEqual(HEqual* equal) OVERRIDE;
void VisitArraySet(HArraySet* equal) OVERRIDE;
+ void VisitTypeConversion(HTypeConversion* instruction) OVERRIDE;
};
void InstructionSimplifier::Run() {
@@ -78,4 +79,12 @@ void InstructionSimplifierVisitor::VisitArraySet(HArraySet* instruction) {
}
}
+void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruction) {
+ if (instruction->GetResultType() == instruction->GetInputType()) {
+ // Remove the instruction if it's converting to the same type.
+ instruction->ReplaceWith(instruction->GetInput());
+ instruction->GetBlock()->RemoveInstruction(instruction);
+ }
+}
+
} // namespace art