summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
authorGuillaume "Vermeille" Sanchez <guillaumesa@google.com>2015-04-20 14:41:30 +0100
committerGuillaume "Vermeille" Sanchez <guillaumesa@google.com>2015-04-23 17:53:17 +0100
commitaf88835231c2508509eb19aa2d21b92879351962 (patch)
tree4ef1c8fb3c5b78175767999a888b0c2cb1ea6485 /compiler/optimizing/instruction_simplifier.cc
parentda93333d568f3c5bd8eeb58341d10a332e1d42bf (diff)
downloadart-af88835231c2508509eb19aa2d21b92879351962.zip
art-af88835231c2508509eb19aa2d21b92879351962.tar.gz
art-af88835231c2508509eb19aa2d21b92879351962.tar.bz2
Remove unnecessary null checks in CheckCast and InstanceOf
Change-Id: I6fd81cabd8673be360f369e6318df0de8b18b634
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 afbc490..40ff098 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -60,6 +60,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;
@@ -161,6 +162,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
@@ -178,6 +183,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.