diff options
author | Guillaume Sanchez <guillaumesa@google.com> | 2015-04-09 21:12:15 +0100 |
---|---|---|
committer | Guillaume Sanchez <guillaumesa@google.com> | 2015-04-10 10:28:02 +0100 |
commit | b19930c5cba3cf662dce5ee057fcc9829b4cbb9c (patch) | |
tree | c226f8fffc4522b273072c516507083e2a77c505 /compiler/optimizing/code_generator_x86.cc | |
parent | 0f88e87085b7cf6544dadff3f555773966a6853e (diff) | |
download | art-b19930c5cba3cf662dce5ee057fcc9829b4cbb9c.zip art-b19930c5cba3cf662dce5ee057fcc9829b4cbb9c.tar.gz art-b19930c5cba3cf662dce5ee057fcc9829b4cbb9c.tar.bz2 |
Follow up of "div/rem on x86 and x86_64", to tidy up the code a little.
Change-Id: Ibf39cbc8ac1d773599d70be2cb1e941674b60f1d
Diffstat (limited to 'compiler/optimizing/code_generator_x86.cc')
-rw-r--r-- | compiler/optimizing/code_generator_x86.cc | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index dac7221..007e25a 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -2229,10 +2229,11 @@ void InstructionCodeGeneratorX86::DivRemOneOrMinusOne(HBinaryOperation* instruct LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(1).IsConstant()); + DCHECK(locations->InAt(1).GetConstant()->IsIntConstant()); Register out_register = locations->Out().AsRegister<Register>(); Register input_register = locations->InAt(0).AsRegister<Register>(); - int imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); + int32_t imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); DCHECK(imm == 1 || imm == -1); @@ -2247,16 +2248,14 @@ void InstructionCodeGeneratorX86::DivRemOneOrMinusOne(HBinaryOperation* instruct } -void InstructionCodeGeneratorX86::DivByPowerOfTwo(HBinaryOperation* instruction) { - DCHECK(instruction->IsDiv()); - +void InstructionCodeGeneratorX86::DivByPowerOfTwo(HDiv* instruction) { LocationSummary* locations = instruction->GetLocations(); Register out_register = locations->Out().AsRegister<Register>(); Register input_register = locations->InAt(0).AsRegister<Register>(); - int imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); + int32_t imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); - DCHECK(instruction->IsDiv() && IsPowerOfTwo(std::abs(imm))); + DCHECK(IsPowerOfTwo(std::abs(imm))); Register num = locations->GetTemp(0).AsRegister<Register>(); __ leal(num, Address(input_register, std::abs(imm) - 1)); @@ -2365,15 +2364,15 @@ void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instr DCHECK_EQ(EAX, first.AsRegister<Register>()); DCHECK_EQ(is_div ? EAX : EDX, out.AsRegister<Register>()); - if (second.IsConstant()) { - int imm = second.GetConstant()->AsIntConstant()->GetValue(); + if (instruction->InputAt(1)->IsIntConstant()) { + int32_t imm = second.GetConstant()->AsIntConstant()->GetValue(); if (imm == 0) { // Do not generate anything for 0. DivZeroCheck would forbid any generated code. } else if (imm == 1 || imm == -1) { DivRemOneOrMinusOne(instruction); } else if (is_div && IsPowerOfTwo(std::abs(imm))) { - DivByPowerOfTwo(instruction); + DivByPowerOfTwo(instruction->AsDiv()); } else { DCHECK(imm <= -2 || imm >= 2); GenerateDivRemWithAnyConstant(instruction); @@ -2444,7 +2443,7 @@ void LocationsBuilderX86::VisitDiv(HDiv* div) { // We need to save the numerator while we tweak eax and edx. As we are using imul in a way // which enforces results to be in EAX and EDX, things are simpler if we use EAX also as // output and request another temp. - if (div->InputAt(1)->IsConstant()) { + if (div->InputAt(1)->IsIntConstant()) { locations->AddTemp(Location::RequiresRegister()); } break; @@ -2518,7 +2517,7 @@ void LocationsBuilderX86::VisitRem(HRem* rem) { // We need to save the numerator while we tweak eax and edx. As we are using imul in a way // which enforces results to be in EAX and EDX, things are simpler if we use EDX also as // output and request another temp. - if (rem->InputAt(1)->IsConstant()) { + if (rem->InputAt(1)->IsIntConstant()) { locations->AddTemp(Location::RequiresRegister()); } break; |