diff options
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index a0de73da32..2d9e35c3b6 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -38,4 +38,21 @@ void InstructionSimplifier::VisitSuspendCheck(HSuspendCheck* check) { block->RemoveInstruction(check); } +void InstructionSimplifier::VisitEqual(HEqual* equal) { + HInstruction* input1 = equal->InputAt(0); + HInstruction* input2 = equal->InputAt(1); + if (input1->GetType() == Primitive::kPrimBoolean && input2->IsIntConstant()) { + if (input2->AsIntConstant()->GetValue() == 1) { + // Replace (bool_value == 1) with bool_value + equal->ReplaceWith(equal->InputAt(0)); + equal->GetBlock()->RemoveInstruction(equal); + } else { + // Replace (bool_value == 0) with !bool_value + DCHECK_EQ(input2->AsIntConstant()->GetValue(), 0); + equal->GetBlock()->ReplaceAndRemoveInstructionWith( + equal, new (GetGraph()->GetArena()) HNot(input1)); + } + } +} + } // namespace art |