summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2015-05-11 13:46:34 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2015-05-11 13:46:34 +0000
commite2243670d3acae8556b47be8bbd9bae3e340541f (patch)
tree3eb8f3478885461cccfd27071885049db5f644a3 /compiler/optimizing/instruction_simplifier.cc
parent796008a32b19d7ce5f49c8e2981f641ba3c28664 (diff)
parent119b21a6dfdb09d983a9e56a837fbf5c98e57096 (diff)
am 119b21a6: Merge "[optimizing] Improve 32 bit long shift by 1."
* commit '119b21a6dfdb09d983a9e56a837fbf5c98e57096': [optimizing] Improve 32 bit long shift by 1.
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc26
1 files changed, 19 insertions, 7 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index e79d4f4bdc..46fad17b8f 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();
+ }
}
}