summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2015-05-11 13:37:09 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-05-11 13:37:09 +0000
commit119b21a6dfdb09d983a9e56a837fbf5c98e57096 (patch)
tree3eb8f3478885461cccfd27071885049db5f644a3 /compiler
parent0e4c27e555d854f00185603138a6434358d07757 (diff)
parentba56d060116d6e145be348fa575314654c6b0572 (diff)
downloadart-119b21a6dfdb09d983a9e56a837fbf5c98e57096.zip
art-119b21a6dfdb09d983a9e56a837fbf5c98e57096.tar.gz
art-119b21a6dfdb09d983a9e56a837fbf5c98e57096.tar.bz2
Merge "[optimizing] Improve 32 bit long shift by 1."
Diffstat (limited to 'compiler')
-rw-r--r--compiler/optimizing/code_generator_x86.cc6
-rw-r--r--compiler/optimizing/instruction_simplifier.cc26
2 files changed, 24 insertions, 8 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index cfb8702..2848a48 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -2830,7 +2830,11 @@ void InstructionCodeGeneratorX86::HandleShift(HBinaryOperation* op) {
void InstructionCodeGeneratorX86::GenerateShlLong(const Location& loc, int shift) {
Register low = loc.AsRegisterPairLow<Register>();
Register high = loc.AsRegisterPairHigh<Register>();
- if (shift == 32) {
+ if (shift == 1) {
+ // This is just an addition.
+ __ addl(low, low);
+ __ adcl(high, high);
+ } else if (shift == 32) {
// Shift by 32 is easy. High gets low, and low gets 0.
codegen_->EmitParallelMoves(
loc.ToLow(),
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();
+ }
}
}