diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-10-01 11:32:17 +0100 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-10-07 21:25:27 +0100 |
commit | 01ef345767ea609417fc511e42007705c9667546 (patch) | |
tree | 8a3cf1b5a576caf212ef31db966b97b6d23aaf98 /compiler/optimizing/instruction_simplifier.cc | |
parent | a9f2904263581f606a5704f2bb74efcecf7e9f97 (diff) | |
download | art-01ef345767ea609417fc511e42007705c9667546.zip art-01ef345767ea609417fc511e42007705c9667546.tar.gz art-01ef345767ea609417fc511e42007705c9667546.tar.bz2 |
Add trivial register hints to the register allocator.
- Add hints for phis, same as first input, and expected registers.
- Make the if instruction accept non-condition instructions.
Change-Id: I34fa68393f0d0c19c68128f017b7a05be556fbe5
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 a0de73d..2d9e35c 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 |