diff options
author | Roland Levillain <rpl@google.com> | 2015-05-11 13:37:09 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-05-11 13:37:09 +0000 |
commit | 119b21a6dfdb09d983a9e56a837fbf5c98e57096 (patch) | |
tree | 3eb8f3478885461cccfd27071885049db5f644a3 /compiler/optimizing/instruction_simplifier.cc | |
parent | 0e4c27e555d854f00185603138a6434358d07757 (diff) | |
parent | ba56d060116d6e145be348fa575314654c6b0572 (diff) | |
download | art-119b21a6dfdb09d983a9e56a837fbf5c98e57096.zip art-119b21a6dfdb09d983a9e56a837fbf5c98e57096.tar.gz art-119b21a6dfdb09d983a9e56a837fbf5c98e57096.tar.bz2 |
Merge "[optimizing] Improve 32 bit long shift by 1."
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index e79d4f4..46fad17 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -137,13 +137,25 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) { HConstant* input_cst = instruction->GetConstantRight(); HInstruction* input_other = instruction->GetLeastConstantLeft(); - if ((input_cst != nullptr) && input_cst->IsZero()) { - // Replace code looking like - // SHL dst, src, 0 - // with - // src - instruction->ReplaceWith(input_other); - instruction->GetBlock()->RemoveInstruction(instruction); + if (input_cst != nullptr) { + if (input_cst->IsZero()) { + // Replace code looking like + // SHL dst, src, 0 + // with + // src + instruction->ReplaceWith(input_other); + instruction->GetBlock()->RemoveInstruction(instruction); + } else if (instruction->IsShl() && input_cst->IsOne()) { + // Replace Shl looking like + // SHL dst, src, 1 + // with + // ADD dst, src, src + HAdd *add = new(GetGraph()->GetArena()) HAdd(instruction->GetType(), + input_other, + input_other); + instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, add); + RecordSimplification(); + } } } |