summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2015-04-23 17:19:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-23 17:19:34 +0000
commit322b389a74177c9d938f1f73d53110623dfc61b6 (patch)
treeb2437d4cdce399ce462d587d9c9c47a8fceb8953 /compiler/optimizing/instruction_simplifier.cc
parent272bf7e60add5f741fb9a2589eaa71945257afcc (diff)
parentaf88835231c2508509eb19aa2d21b92879351962 (diff)
downloadart-322b389a74177c9d938f1f73d53110623dfc61b6.zip
art-322b389a74177c9d938f1f73d53110623dfc61b6.tar.gz
art-322b389a74177c9d938f1f73d53110623dfc61b6.tar.bz2
Merge "Remove unnecessary null checks in CheckCast and InstanceOf"
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 225af77..2df7c16 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -62,6 +62,7 @@ class InstructionSimplifierVisitor : public HGraphVisitor {
void VisitSub(HSub* instruction) OVERRIDE;
void VisitUShr(HUShr* instruction) OVERRIDE;
void VisitXor(HXor* instruction) OVERRIDE;
+ void VisitInstanceOf(HInstanceOf* instruction) OVERRIDE;
OptimizingCompilerStats* stats_;
bool simplification_occurred_ = false;
@@ -159,6 +160,10 @@ void InstructionSimplifierVisitor::VisitNullCheck(HNullCheck* null_check) {
void InstructionSimplifierVisitor::VisitCheckCast(HCheckCast* check_cast) {
HLoadClass* load_class = check_cast->InputAt(1)->AsLoadClass();
+ if (!check_cast->InputAt(0)->CanBeNull()) {
+ check_cast->ClearMustDoNullCheck();
+ }
+
if (!load_class->IsResolved()) {
// If the class couldn't be resolve it's not safe to compare against it. It's
// default type would be Top which might be wider that the actual class type
@@ -176,6 +181,12 @@ void InstructionSimplifierVisitor::VisitCheckCast(HCheckCast* check_cast) {
}
}
+void InstructionSimplifierVisitor::VisitInstanceOf(HInstanceOf* instruction) {
+ if (!instruction->InputAt(0)->CanBeNull()) {
+ instruction->ClearMustDoNullCheck();
+ }
+}
+
void InstructionSimplifierVisitor::VisitSuspendCheck(HSuspendCheck* check) {
HBasicBlock* block = check->GetBlock();
// Currently always keep the suspend check at entry.