summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2015-01-26 18:54:32 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2015-01-29 12:01:26 +0000
commit10e244f9e7f6d96a95c910a2bedef5bd3810c637 (patch)
treebc2b90ce716129115c05f79e21c58fe13b01fd20 /compiler/optimizing/instruction_simplifier.cc
parentab7f56d9b9838811cb01773e45999e2cda4aa03a (diff)
optimizing: NullCheck elimination
How it works: - run a type analysis to propagate null information on instructions - during the last instruction simplifier remove null checks for which the input is known to be not null The current type analysis is actually a nullability analysis but it will be reused in follow up CLs to propagate type information: so it keeps the more convenient name. Change-Id: I54bb1d32ab24604b4d677d1ecdaf8d60a5ff5ce9
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 63bc4ae671..17c8f337ca 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -27,6 +27,7 @@ class InstructionSimplifierVisitor : public HGraphVisitor {
void VisitEqual(HEqual* equal) OVERRIDE;
void VisitArraySet(HArraySet* equal) OVERRIDE;
void VisitTypeConversion(HTypeConversion* instruction) OVERRIDE;
+ void VisitNullCheck(HNullCheck* instruction) OVERRIDE;
};
void InstructionSimplifier::Run() {
@@ -34,6 +35,14 @@ void InstructionSimplifier::Run() {
visitor.VisitInsertionOrder();
}
+void InstructionSimplifierVisitor::VisitNullCheck(HNullCheck* null_check) {
+ HInstruction* obj = null_check->InputAt(0);
+ if (!obj->CanBeNull()) {
+ null_check->ReplaceWith(obj);
+ null_check->GetBlock()->RemoveInstruction(null_check);
+ }
+}
+
void InstructionSimplifierVisitor::VisitSuspendCheck(HSuspendCheck* check) {
HBasicBlock* block = check->GetBlock();
// Currently always keep the suspend check at entry.